Exemplo n.º 1
0
        public ActionResult Register()
        {
            // name of the inputs
            string name             = Request["name"];
            string email            = Request["email"];
            string password         = Request["password"];
            string confirm_password = Request["confirm_password"];

            //if the customer does not exist in the data base table
            if (Database.getContext().Customer.SingleOrDefault(m => m.Email == email) == null)
            {
                Customer customer = new Customer()
                {
                    Name     = name,
                    Email    = email,
                    Password = dHash.make(password),
                    _token   = dHash.GetMd5(email),
                };
                // inserting in the database
                Database.getContext().Customer.Add(customer);
                Database.getContext().SaveChanges();
                ViewBag.email = email;
                //Session["Customer"] = customer;
                //Session["LoginSuccess"] = "LoginSuccess";
                dMailer.EmailVerificationMail(email, dHash.GetMd5(email));
                return(View("Address"));
            }
            else
            {
                Session["UserExists"] = true;
                Response.Write("User Already Exists");
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 2
0
        public ActionResult EmailVerify(string token)
        {
            Customer customer = Database.getContext().Customer.FirstOrDefault(m => m._token == token);

            //Response.Write(customer.Name);
            if (customer != null)
            {
                customer._token = null;
                Database.getContext().SaveChanges();
                Session["EmailVerificationSuccess"] = "EmailVerificationSuccess";
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                Response.Write("token expired!");
            }
            return(Content("Something wrong!"));
        }
Exemplo n.º 3
0
        public ActionResult Login(FormCollection formCol)
        {
            string   email    = formCol["email"];
            string   password = formCol["password"];
            Customer customer = Database.getContext().Customer.FirstOrDefault(m => m.Email == email);

            if ((customer != null) && (bool)dHash.verify(password, customer.Password))
            {
                Session["Customer"]     = customer;
                Session["LoginSuccess"] = "LoginSuccess";
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                Session["CustomerError"] = "CustomerError";
            }

            return(RedirectToAction("Index", "Authentication"));
        }
Exemplo n.º 4
0
        public ActionResult Address(Customer cust, FormCollection formColct)
        {
            string   email    = formColct["email"];
            Customer customer = Database.getContext().Customer.SingleOrDefault(m => m.Email == email);

            Address address = new Address()
            {
                Customer_Id = customer.Id,
                City        = formColct["city"],
                Zip         = Convert.ToInt32(formColct["zip"]),
                Details     = formColct["details"],
            };

            Database.getContext().Address.Add(address);
            Database.getContext().SaveChanges();
            Session["RgistrationSuccess"] = "RgistrationSuccess";
            Session["Customer"]           = customer;
            Session["LoginSuccess"]       = "LoginSuccess";
            return(RedirectToAction("Index", "Home"));
        }