public IHttpActionResult ChangeUserRole(int userId, UserForChangeRoleDTO model) { if (!ModelState.IsValid) { return(BadRequest("Rol ismi alınamadı")); } var userRole = UserManager.GetRoles(userId).First(); try { UserManager.RemoveFromRole(userId, userRole); UserManager.AddToRole(userId, model.name); } catch (Exception) { throw; } return(Ok()); }
public async Task <IActionResult> ChangeUserRole(int userId, UserForChangeRoleDTO model) { if (!ModelState.IsValid) { return(BadRequest(Messages.ModelNullOrEmpty)); } var user = await _authService.FindUserByUserIdAsync(userId); if (!user.Success) { return(BadRequest(user.Message)); } var userRole = model.Name; var result = await _authService.ChangeUserRoleAsync(user.Data, userRole); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }