public async Task <IActionResult> DeleteUserRole(UserViewModel model) { ViewData["Title"] = "Edit a User"; var user = await UserManagerAgent.FindByNameAsync(model?.UserName).ConfigureAwait(false); if (await RoleManagerAgent.RoleExistsAsync(model.NewRole).ConfigureAwait(false) && await UserManagerAgent.IsInRoleAsync(user, model.NewRole).ConfigureAwait(false)) { await UserManagerAgent.RemoveFromRoleAsync(user, model.NewRole).ConfigureAwait(false); } model = _mapper.Map <UserViewModel>(user); model.MemberRoles.AddRange(await UserManagerAgent.GetRolesAsync(user).ConfigureAwait(false)); model.AllRoles.AddRange(GetAllRolesAsSelectList()); return(View("EditUser", model)); }