Пример #1
0
        public ActionResult Create(Admin.Models.DataModel.Customer customer, string RePassword)
        {
            if (db.Customers.SingleOrDefault(x => x.Username == customer.Username) != null)
            {
                ViewBag.UsernameEror = "Tài khoản đã tồn tại";
                return(View(customer));
            }
            if (RePassword != customer.Password)
            {
                ViewBag.UsernameEror = "Xác nhận mật khẩu không chính xác";
                return(View(customer));
            }
            customer.Id = Guid.NewGuid().ToString().Replace("-", string.Empty);

            customer.Password = Encryptor.MD5Hash(customer.Password);

            db.Customers.Add(customer);
            db.SaveChanges();
            return(RedirectToAction("Login", "Login"));
        }
Пример #2
0
        public ActionResult Edit(Admin.Models.DataModel.Customer customer)
        {
            if (Session["customer"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            var oldCustomers = db.Customers.Find(customer.Id);

            if (oldCustomers == null)
            {
                return(View(oldCustomers));
            }
            oldCustomers.Name            = customer.Name;
            oldCustomers.Phone           = customer.Phone;
            oldCustomers.BankAccountCode = customer.BankAccountCode;
            oldCustomers.Email           = customer.Email;
            oldCustomers.Address         = customer.Address;
            oldCustomers.Male            = customer.Male;
            db.SaveChanges();
            return(View());
        }