Example #1
0
 public int Kiemtratontai(string id)
 {
     for (int i = 0; i < ManagerObject.getIntance().giohang.getGiohang().Count; i++)
     {
         if (ManagerObject.getIntance().giohang.getGiohang()[i].sanpham.MASP == id)
         {
             return(i);
         }
     }
     return(-1);
 }
Example #2
0
 public ActionResult checkout(DonHangTongQuan dhtq)
 {
     if (Session.Count > 0)
     {
         DonHangModel dh     = new DonHangModel();
         var          userid = (Userlogin)Session[Commonconst.USER_SESSION];
         var          id     = userid.UserId;
         dh.Luudonhang(dhtq, id, ManagerObject.getIntance().giohang);
         return(RedirectToAction("Xemdonhang", "Home"));
     }
     else
     {
         return(RedirectToAction("Login", "User"));              //xu li trang redirec
     }
 }
Example #3
0
 public ActionResult Addcart(string sp, int quantity)
 {
     try
     {
         var temp  = db.SPHAMs.Find(sp);
         int index = Kiemtratontai(sp);
         if (index == -1)
         {
             ChiTietGioHang tam = new ChiTietGioHang();
             tam.sanpham = temp;
             tam.soluong = quantity;
             ManagerObject.getIntance().giohang.addCart(tam);
         }
         else
         {
             ManagerObject.getIntance().giohang.getGiohang()[index].soluong += quantity;
         }
         return(PartialView("Cart", ManagerObject.getIntance().giohang));
     }
     catch (Exception)
     { return(Json("fail")); }
 }
Example #4
0
 public ActionResult XuLiGioHang()
 {
     return(PartialView("Basexuligiohang", ManagerObject.getIntance().giohang));
 }
Example #5
0
 public ActionResult XoaGioHang(int index)
 {
     ManagerObject.getIntance().giohang.removeCart(index);
     return(RedirectToAction("XuLiGioHang"));
 }
Example #6
0
 public ActionResult ThayDoiSoLuong(int index, string value)
 {
     ManagerObject.getIntance().giohang.Changequanlity(index, value);
     return(RedirectToAction("XuLiGioHang"));
 }
Example #7
0
 public ActionResult CartTitle()
 {
     return(PartialView("Cart", ManagerObject.getIntance().giohang));
 }
Example #8
0
 public ActionResult Cart()
 {
     return(View(ManagerObject.getIntance().giohang));
 }