public async Task <IHttpActionResult> AddRolesToUser(UpdateUserModel userModel) { var user = await repository.FindByName(userModel.UserName); if (user == null) { return(NotFound()); } foreach (var role in userModel.Roles) { if (user.Claims.FirstOrDefault(p => p.ClaimType == ClaimTypes.Role && p.ClaimValue == role) == null) { user.Claims.Add(new IdentityUserClaim() { ClaimType = ClaimTypes.Role, ClaimValue = role, UserId = user.Id }); } } await repository.UpdateUser(user); return(Ok()); }