public ActionResult EditProfile(ProfileViewModel profile) { if (ModelState.IsValid) { var usersRepository = RepositoryFactory.GetUsersRepository(); var user = RepositoryFactory.GetUsersRepository().GetById(profile.Id); UpdateUserInfo(user, profile); using (new UnitOfWork(EntitiesContext.Current)) { usersRepository.Update(user); } SetViewNotificationMessage(Resources.Resources.RecordChangedNotification); return RedirectToAction("ShowProfile", new { id = profile.Id }); } SetViewErrorMessage(Resources.ErrorMessages.EntityCommitError); return View(profile); }
private void UpdateUserInfo(User user, ProfileViewModel profile) { user.Name = profile.Name; user.Email = profile.Email; user.IsBlocked = profile.IsBlocked; if (profile.RoleId.HasValue) user.RoleId = profile.RoleId.Value; user.Details.BlockDate = profile.BlockDate; user.Details.BlockReason = profile.BlockReason; }