コード例 #1
0
        public void OnPost()
        {
            if (!ModelState.IsValid)
            {
                return;
            }
            if (_userService.HasExist(Register.Name))
            {
                ModelState.AddModelError("Register.Name", "*用户名已经存在");
                return;
            }
            _userService.Register(Register.Name, Register.PassWord);

            Response.Redirect("Index");
        }
コード例 #2
0
        //[AutoValidationFilter]
        public ActionResult Home(UserModel user, UserModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            //if (model.Captcha != Session[CaptchaController.CAPTCHA].ToString())
            //{
            //    ModelState.AddModelError("Captcha", "验证码输入错误");
            //    return View(model);

            //}
            if (_userRepository.HasExist(user.UserName))
            {
                ModelState.AddModelError("user.UserName", "*用户名重复");
            }
            _userRepository.Register(user.UserName, user.Password);

            //CurrentData.db.Users.Add(user);
            //CurrentData.db.SaveChanges();
            return(Redirect("/Register/Login"));
        }