示例#1
0
        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")));
        }
示例#2
0
        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()));
        }
示例#3
0
        public ActionResult Edit(int id)
        {
            var user = userRepository.GetById(id);

            return(View("Edit", EditViewData.WithUser(user)));
        }
示例#4
0
 public ActionResult New()
 {
     return(View("Edit", EditViewData.WithUser(Shop.User.DefaultUser)));
 }