Ejemplo n.º 1
0
        public ActionResult SignUp(ViewRegister register)
        {
            if (ModelState.IsValid)
            {
                if (db.Users.SingleOrDefault(t => t.user_email == register.Email) != null)
                {
                    TempData["noti_register"] = "Email đã tồn tại!";
                    return(View(register));
                }
                var user = new User()
                {
                    user_email = register.Email,
                    user_pass  = register.Password,
                    user_name  = register.DisplayName,
                    user_birth = register.DateOfBirth,
                    user_phone = register.Phone,
                    user_sex   = register.Sex,
                    user_img   = "notimg.png"
                };
                usersDAO.Add(user);

                var        user1  = db.Users.FirstOrDefault(t => t.user_email == register.Email && t.user_pass == register.Password);
                HttpCookie cookie = new HttpCookie("user_id", user1.user_id.ToString());
                cookie.Expires.AddDays(10);
                Response.Cookies.Set(cookie);
                return(RedirectToAction("Info"));
            }
            return(View(register));
        }