Пример #1
0
 public ActionResult Index()
 {
     using (LTWebEntities db = new LTWebEntities())
     {
         var data = (from s in db.Products select s).ToList();
         ViewBag.products = data;
     }
     return(View());
 }
Пример #2
0
 public ActionResult SignUp(FormCollection fields)
 {
     if (fields["Password"] != fields["PasswordAgain"])
     {
         return(View());
     }
     using (LTWebEntities _db = new LTWebEntities())
     {
         User a = new User();
         a.Username = fields["Username"];
         a.Email    = fields["gmail"];
         a.Password = fields["Password"];
         a.Phone    = int.Parse(fields["numberPhone"]);
         a.Lever    = 3;
         a.HoTen    = "";
         a.DiaChi   = "";
         a.ngaySinh = DateTime.Now;
         _db.Users.Add(a);
         _db.SaveChanges();
     }
     return(View());
 }
Пример #3
0
        public ActionResult SignIn(string Username, string Password)
        {
            User a = new User();

            using (LTWebEntities _db = new LTWebEntities())
            {
                a = _db.Users.Where(x => x.Username == Username).FirstOrDefault();
            }

            if (a == null)
            {
                return(View());
            }

            if (a.Password == Password && a.Lever == 1)
            {
                Session["Username"] = Username;
                Session["Lever"]    = "1";
                Session["Password"] = Password;
                return(RedirectToAction("Index", "Admin"));
            }
            else if (a.Password == Password && a.Lever == 3)
            {
                Session["Username"] = Username;
                Session["Lever"]    = "3";
                Session["Password"] = Password;
                if (Session["giohang"] != null)
                {
                    return(RedirectToAction("Index", "Cart"));
                }
                return(RedirectToAction("HomeBHX", "HomeBHX"));
            }
            else
            {
                return(View("SignIn"));
            }
        }