public void EditUser(AccountViewModel accountViewModel) { var userToEdit = GetUser(accountViewModel.UserProfile.UserId); if (userToEdit != null) { userToEdit.FirstName = accountViewModel.UserProfile.FirstName; userToEdit.LastName = accountViewModel.UserProfile.LastName; userToEdit.CompanyId = accountViewModel.UserProfile.CompanyId; _db.SaveChanges(); } }
public ActionResult Edit(AccountViewModel accountViewModel) { try { _accountHandler.EditUser(accountViewModel); var userRoles = accountViewModel.UserRole; accountViewModel = _accountHandler.GetUser(accountViewModel.UserProfile.UserId); foreach (var role in userRoles) { if(role.Selected) { if (!Roles.FindUsersInRole(role.RoleName, accountViewModel.UserProfile.UserName).Contains(accountViewModel.UserProfile.UserName)) Roles.AddUserToRole(accountViewModel.UserProfile.UserName, role.RoleName); } else { if (Roles.FindUsersInRole(role.RoleName, accountViewModel.UserProfile.UserName).Contains(accountViewModel.UserProfile.UserName)) Roles.RemoveUserFromRole(accountViewModel.UserProfile.UserName, role.RoleName); } } return RedirectToAction("Index"); } catch { return RedirectToAction("Index"); } }
public void EditUser(AccountViewModel accountViewModel) { _accountRepository.EditUser(accountViewModel); }
public void EditUser(AccountViewModel accountViewModel) { _accountManager.EditUser(accountViewModel); }