public ActionResult Edit(User user, string password) { if (!ModelState.IsValid) { return(View("Edit", EditViewData.WithUser(user))); } if (!string.IsNullOrEmpty(password)) { user.Password = userService.HashPassword(password); } return(View("Edit", EditViewData.WithUser(user).WithMessage("Changes have been saved"))); }
public ActionResult New(User user, string password) { if (!ModelState.IsValid) { return(View("Edit", EditViewData.WithUser(user))); } if (!string.IsNullOrEmpty(password)) { user.Password = userService.HashPassword(password); } else { ModelState.AddModelError("password", "Password is required"); return(View("Edit", EditViewData.WithUser(user))); } userRepository.SaveOrUpdate(user); Message = "User has been added."; return(this.RedirectToAction(c => c.Index())); }
public ActionResult Edit(int id) { var user = userRepository.GetById(id); return(View("Edit", EditViewData.WithUser(user))); }
public ActionResult New() { return(View("Edit", EditViewData.WithUser(Shop.User.DefaultUser))); }