Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Best way to extend UserManager #7359


User avatar
0
rvanwoezik created

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)
  • User Avatar
    0
    maliming created
    Support Team

    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.

  • User Avatar
    0
    rvanwoezik created

    Hi @maliming, thanks for your quick reply. Shoud i use the IRepository<User, long> in my method to find the user??

  • User Avatar
    0
    maliming created
    Support Team

    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.

  • User Avatar
    0
    rvanwoezik created

    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

  • User Avatar
    0
    maliming created
    Support Team

    I suggest you use [UnitOfWork] for your method.