private cEditorResult CreateAndAddToRole(ApplicationUser user, string roleName) { var role = FillRole(roleName); var roleResult = CreateRole(role); if (roleResult.Succeeded) { var result = AddToRole(user, roleName); return result; } else { return cEditorResult.Failed(roleResult.Errors); } }
private cEditorResult AddToRole(ApplicationUser user, string roleName) { var addToRoleResult = _userManager.AddToRoleAsync(user.Id, roleName).Result; if (addToRoleResult.Succeeded) { SignIn(user); return cEditorResult.Success(); } else { return cEditorResult.Failed(addToRoleResult.Errors); } }
private IdentityResult CreateUser(ApplicationUser user, string password) { var result = _userManager.CreateAsync(user, password).Result; return result; }
private void SignIn(ApplicationUser user, bool isPersistent = false, bool rememberBrowser = false, int waitSeconds = 2) { _signInManager.Value.SignInAsync(user, isPersistent: isPersistent, rememberBrowser: rememberBrowser) .Wait(TimeSpan.FromSeconds(waitSeconds)); }
private ApplicationUser FillUser(string userName, string email) { var result = new ApplicationUser { UserName = userName, Email = email }; return result; }