Exemple #1
0
        private static async Task CreateUserSync(UserManager <ApplicationUser> userManager, UserTemplate userTemplate, ApplicationUser user)
        {
            await userManager.CreateAsync(user, userTemplate.Password);

            await userManager.AddToRolesAsync(user, userTemplate.Roles);
        }
Exemple #2
0
 private static void CreateUserFromTemplate(UserManager <ApplicationUser> userManager, UserTemplate userTemplate)
 {
     if (!userManager.Users.Any(user => user.UserName == userTemplate.UserName))
     {
         var user = new ApplicationUser()
         {
             UserName = userTemplate.UserName, Email = userTemplate.Email
         };
         CreateUserSync(userManager, userTemplate, user);
     }
 }