Ejemplo n.º 1
0
        public ActionResult SignUp(User U, bool condition)
        {
            if (U.Fname == "" || U.lname == "" || U.Email == "" || U.password == "" || U.birthday == "10/24/1900" || U.gender == "" || condition == false)
            {
                return(Json(4, JsonRequestBehavior.DenyGet));
            }
            VerifyEmail v          = new VerifyEmail();
            int         validation = v.VEmail(U.Email);

            if (validation == 0)
            {
                //Email is valid
                Rep_user RU    = new Rep_user();
                SHA256   Crypt = new SHA256();
                U.password = Crypt.DataSHA256(U.password);
                var    signUp = RU.AddUser(U);
                var    User   = db.Users.Where(c => c.Email.Equals(U.Email) && c.password.Equals(U.password)).Single().id;
                string sp     = Server.MapPath("\\Content\\User\\");
                Directory.CreateDirectory(sp + "\\" + User);
                //User login

                HttpCookie idLoginCookie = new HttpCookie("idlogin", User.ToString());
                Response.Cookies["idlogin"].Secure = true;
                Response.Cookies.Add(idLoginCookie);
                return(Json(1, JsonRequestBehavior.DenyGet));
            }
            else if (validation == 1)
            {
                //email exist in Database
                return(Json(2, JsonRequestBehavior.DenyGet));
            }
            else
            {
                //email format is not valid
                return(Json(3, JsonRequestBehavior.DenyGet));
            }
        }