I have added an external Id to users: SomId. Now i want to add a GetUserBySomId(int somId)
What is the best Zero way to do that?
Thanks in advance, Rene van Woezik
5 Answer(s)
-
0
src\MyCompanyName.AbpZeroTemplate.Core\Authorization\Users\UserManager.cs
You can define the method directly in the
UserManager
.Then inject the
UserManager
elsewhere and call the relevant methods. -
0
Hi @maliming, thanks for your quick reply. Shoud i use the IRepository<User, long> in my method to find the user??
-
0
The UserManager constructor injects some services, such as UserStore. You can use them directly, There are also many methods in the base class that you can use.
-
0
Thnx! This is wat i have done in UserManager.cs:
public User GetUserBySomId(int somId) { return Users.FirstOrDefault(u => u.SpotOnMedicsId == somId); }
And it works -
0
I suggest you use [UnitOfWork] for your method.