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); }
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 } }
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")); } }
public ActionResult XuLiGioHang() { return(PartialView("Basexuligiohang", ManagerObject.getIntance().giohang)); }
public ActionResult XoaGioHang(int index) { ManagerObject.getIntance().giohang.removeCart(index); return(RedirectToAction("XuLiGioHang")); }
public ActionResult ThayDoiSoLuong(int index, string value) { ManagerObject.getIntance().giohang.Changequanlity(index, value); return(RedirectToAction("XuLiGioHang")); }
public ActionResult CartTitle() { return(PartialView("Cart", ManagerObject.getIntance().giohang)); }
public ActionResult Cart() { return(View(ManagerObject.getIntance().giohang)); }