//kiểm tra captch
        //Lưu thông tin đăng kí vào CSDL
        public ActionResult Register(UserRegisting user)
        {
            if (!ModelState.IsValid)
            {
                // TODO: Captcha validation failed, show error message
                ViewBag.ErrorMsg = "Incorrect CAPTCHA code!";
            }
            else
            {
                // TODO: Captcha validation passed, proceed with protected action
                var u = new ClientUser
                {
                    f_Username = user.Username,
                    f_Password = Ulti.Md5Hash(user.Password),
                    f_Name     = user.Name,
                    f_Email    = user.Email,
                    f_DOB      = DateTime.ParseExact(user.DOB, "d/m/yyyy", null)
                };

                CSDLQLBH.InsertUser(u);

                Session["Registered"] = 1;
                return(RedirectToAction("Login", "Account"));
            }
            return(View());
        }
        // GET: Account/Register
        public ActionResult Register()
        {
            var u = new UserRegisting
            {
                Username       = "******",
                Password       = "******",
                PasswordRetype = "1234",
                Name           = "user 0009",
                DOB            = "12/6/1999",
            };

            return(View(u));
        }
Exemplo n.º 3
0
        public ActionResult Register(UserRegisting user)
        {
            var u = new User
            {
                f_UserName = user.UserName,
                f_Password = Ulti.Md5Hash(user.Password),
                f_Name     = user.Name
            };

            using (var dc = new QLKSEntities())
            {
                dc.Users.Add(u);
                dc.SaveChanges();
            }
            return(View());
        }