Ejemplo n.º 1
0
        public ActionResult Register([Bind(Include = "CustomerName,CustomerBirthday,CustomerGender,CustomerEmail,CustomerPhone,CustomerAddress,CustomerPass,CustomerAccount")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                if (CheckEmail(customer.CustomerEmail))
                {
                    ModelState.AddModelError("", "Email is Existed!");
                }
                else
                if (CheckUserName(customer.CustomerAccount))
                {
                    ModelState.AddModelError("", "Account is Existed!");
                }
                else
                {
                    string password = customer.CustomerPass;
                    customer.CustomerPass = EncryptData.md5(password);
                    db.Customers.Add(customer);
                    db.SaveChanges();
                    InsetToOrder(customer.CustomerAccount, EncryptData.md5(password));
                    return(RedirectToAction("LoginCustomer"));
                }
            }
            List <CartItem> cartItems = (List <CartItem>)Session["CartSession"];;

            if (cartItems != null)
            {
                ViewBag.itemCart = cartItems.Count;
            }
            else
            {
                ViewBag.itemCart = 0;
            }
            return(View(customer));
        }
Ejemplo n.º 2
0
        protected override void Seed(BookContext context)
        {
            Account acount = new Account()
            {
                Password = EncryptData.md5("abc@1234"),
                Username = "******",
                RoleName = "Admin"
            };

            context.Accounts.Add(acount);

            Author author = new Author()
            {
                AuthorName    = "Tô Hoài",
                AuthorSummary = "Tô Hoài sinh ra tại quê nội ở thôn Cát Động, Thị trấn Kim Bài, huyện Thanh Oai, tỉnh Hà Đông cũ trong một gia đình thợ thủ công. Tuy nhiên, ông lớn lên ở quê ngoại là làng Nghĩa Đô, huyện Từ Liêm, phủ Hoài Đức, tỉnh Hà Đông (nay thuộc phường Nghĩa Đô, quận Cầu Giấy, Hà Nội, Việt Nam[2]). Bút danh Tô Hoài gắn với hai địa danh: sông Tô Lịch và phủ Hoài Đức."
            };

            context.Authors.Add(author);

            Production production = new Production()
            {
                ProductionName = "Kim đồng"
            };

            context.Productions.Add(production);

            context.SaveChanges();
        }
Ejemplo n.º 3
0
        public ActionResult LoginCustomer(LoginModel loginModel)
        {
            string pass = EncryptData.md5(loginModel.Password);

            InsetToOrder(loginModel.UserName, pass);

            return(RedirectToAction("SubmitSuccess"));
        }
Ejemplo n.º 4
0
        public bool login(string userName, string password)
        {
            string         pass    = EncryptData.md5(password);
            List <Account> accouts = db.Accounts.ToList();

            foreach (var item in accouts)
            {
                string pass1 = item.Password;
                if (item.Username.Equals(userName) && item.Password.Equals(pass))
                {
                    return(true);
                }
            }
            return(false);
        }