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

Assign UserManager to ‘EmailService’ class #1087


User avatar
0
zana created

How can I assign the ‘EmailService’ property on the UserManager to the ‘EmailService’ class Can I extend the UserManager : AbpUserManager<Tenant, Role, User> in IdentityConfig?

ex: /***************************************/ public class ApplicationRoleManager : RoleManager<IdentityRole> { public ApplicationRoleManager(IRoleStore<IdentityRole,string> roleStore) : base(roleStore) { }

    public static ApplicationRoleManager Create(IdentityFactoryOptions&lt;ApplicationRoleManager&gt; options, IOwinContext context)
    {
        return new ApplicationRoleManager(new RoleStore&lt;IdentityRole&gt;(context.Get&lt;ApplicationDbContext&gt;()));
    }
}

public class EmailService : IIdentityMessageService

/***********************************/


4 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    How... I did not understand your question. Are you using "mudule zero" template? If so, there is already a UserManager class in the solution. But did not understand "How can I assign the ‘EmailService’ property on the UserManager to the ‘EmailService’ class".

  • User Avatar
    0
    zana created

    Yes, Im using "mudule zero" template :), and there is already a UserManager class in the solution. I need Send email by UserManager.SendEmailAsync, and implment this code:

    public class EmailService : IIdentityMessageService { public Task SendAsync(IdentityMessage message) { // Plug in your email service here to send an email. return configSendGridasync(message); //return Task.FromResult(0); }

  • User Avatar
    0
    zana created

    I customs Email Service and integrated with external email provider Sendgrid, and assign class "EmailService" to EmailService property via UserManager constructor

    As UserManager constructor:

            this.EmailService = new EmailService();
            this.SmsService = new SmsService();
    

    and Create Classes

    1. public class EmailService : IIdentityMessageService
       {
            public Task SendAsync(IdentityMessage message)
      
    2.   public class SmsService : IIdentityMessageService
       {
           public Task SendAsync(IdentityMessage message)
      

    But NO hit :(

  • User Avatar
    0
    hikalkan created
    Support Team

    Don't use "new", we are using dependency injection (DI) (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Dependency-Injection">http://www.aspnetboilerplate.com/Pages/ ... -Injection</a>). So, register your emailservice to DI and inject into UserManager.