public JsonResult DatHang(string tenkh, string email, string diachinhan, string sdtnhan, int trangthai) { //lay thong tin cac mat hang dat tu session Khachhang kh = new Khachhang(); kh.tenkh = tenkh; kh.email = email; kh.sdt = sdtnhan; kh.diachi = diachinhan; kh.email = email; kh.trangthai = trangthai; int thanhtien = 0; List <CTDHang> ds = new List <CTDHang>(); int total = 0; if (Session["GioHang"] == null) { Session["GioHang"] = new List <CTDHang>(); thanhtien = 0; } else { ds = Session["GioHang"] as List <CTDHang>; thanhtien = Convert.ToInt32(ds.Sum(s => s.DonGia * s.SoLuong)); } ds = Session["GioHang"] as List <CTDHang>; caycanhModel a = new caycanhModel(); List <caycanh> dsss = a.LaySPham(); foreach (CTDHang ct in ds) { foreach (caycanh sp in dsss) { if (sp.macaycanh == ct.MaSP) { a.SuaSLSP(ct.MaSP, ct.SoLuong); } } } checkoutBus mhb = new checkoutBus(); mhb.MuaHang(kh, thanhtien, ds, diachinhan, sdtnhan, trangthai); Session["GioHang"] = null; return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); }
public List <caycanh> LaySPham() { List <caycanh> lsp = spm.LaySPham(); return(lsp); }
public List <caycanh> LaySanPhamTK(string tk) { return(db.LaySPham().Where(x => (x.tencaycanh.ToLower().Contains(tk.ToLower()))).ToList()); }