Hi,
How can I Hard delete users? I am writing some integration tests and I need to create and delete Test data, including users.
Thanks
7 Answer(s)
-
0
Hi,
You can use HardDelete of UserRepository, see https://aspnetboilerplate.com/Pages/Documents/Data-Filters#isoftdelete
-
0
Thanks, it is working now but I have another problem. User settings are not cascade deleted so I need to remove them before I remove the user. I found some methods to get or change settings but I don't know how to remove them.
-
0
Hi @josus,
Deleting a setting is not implemented. However, changing a setting to its default value will delete it.
-
0
Hi!
It is working fine using IRepository<Setting, long>.Delete(). It works like a HardDelete :-). So, one more question, When creating the users, I want some of them created with IsActive set to false. However, they are all created as active... this is my code:
var userId = await _userRepository.InsertOrUpdateAndGetIdAsync(new User { ... IsActive = data.IsUserActive, ... });
After create I add the user to an OU (_userManager.AddToOrganizationUnit)... Could be this action activating the user again?
Thanks!
-
0
Hi @josus
After create I add the user to an OU (_userManager.AddToOrganizationUnit)... Could be this action activating the user again?
I don't think this because related code block doesn't change User's IsActive property, see https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.ZeroCore/Authorization/Users/AbpUserManager.cs#L745
Could you share your
InsertOrUpdateAndGetIdAsync
method and the test you are using this method ? -
1
Hi!!
I finally found the problem. So, we have Person entity related to user, I am creating test people with a 1-1 relation with users. The Person code clock is something like this:
var person = new Person { Name = "Person Name", .... User = new User { ... IsActive = false ... }, ... }; await _personRepository.InsertAsync(person);
Saving the person changes the User to Active so I need to set it to false after this action.
Now is working well.
Thanks!
-
0
Great :)