public ActionResult Edit(int id, string returnUrl) { User user = UserService.GetById(id); // if nothing was found // go back by returnUrl if (user == null) return RedirectToLocal(returnUrl); UserEditViewModel model = new UserEditViewModel() { Id = user.Id, InnerId = user.InnerId, Login = user.UserLogInAttributes.Login, Name = user.Name, Password = user.UserLogInAttributes.Password, ConfirmPassword = string.Empty }; return View(model); }
public ActionResult Edit(UserEditViewModel model, string returnUrl) { if (ModelState.IsValid) { User user = UserService.GetById(model.Id); // if nothing was found // go back by returnUrl if (user == null) return RedirectToLocal(returnUrl); user.InnerId = model.InnerId; user.Name = model.Name; user.UserLogInAttributes.Login = model.Login; user.UserLogInAttributes.Password = model.Password; var updatedUser = UserService.Update(user); return RedirectToAction("Details", "User", new { id = updatedUser.Id, returnUrl = string.Empty }); } return View(model); }