public async Task <IActionResult> EditRole(string id, List <string> roles) { IdentityUser user = _userManager.GetById(id); if (user != null) { var userRoles = _userManager.GetRolesByUser(user.UserName); var addedRoles = roles.Except(userRoles); var removedRoles = userRoles.Except(roles); _userManager.AddRoles(addedRoles.ToList(), user.UserName); _userManager.RemoveRoles(removedRoles.ToList(), user.UserName); return(Ok("Ok")); } return(NotFound()); }