public async Task <ActionResult> ChangeRole(UserRoleViewModel model)
        {
            var currentRole = _userManager.GetRole(model.UserId);

            if (currentRole != model.SelectedRole)
            {
                var currentUser = await _userManager.FindByIdAsync(model.UserId);

                await _userManager.RemoveFromRoleAsync(model.UserId, currentRole);

                await _userManager.AddToRoleAsync(model.UserId, model.SelectedRole);

                await _userManager.UpdateAsync(currentUser);
            }
            return(RedirectToAction("ManageUserRoles"));
        }
Beispiel #2
0
 public Task <IdentityResult> AddToRoleAsync(string userId, string roleName)
 {
     return(_userManagerFacade.AddToRoleAsync(userId, roleName));
 }