public IEnumerable <HangHoaBan> listCTDH(long ID) { List <CHITIETDONHANG> list = db.CHITIETDONHANGs.Where(x => x.IDDONHANG == ID).ToList(); foreach (CHITIETDONHANG ctdh in list) { HangHoaBan hhb = new HangHoaBan(ctdh.MASP, ctdh.SOLUONG); SanPham sp = db.SanPhams.Find(ctdh.MASP); hhb.name = sp.TENSP; hhb.link_anh = sp.LINK_ANH; hhb.price = sp.GIASP; listHangHoa.Add(hhb); } return(listHangHoa); }
public ActionResult Add(string MASP) { SanPham sp = db.SanPhams.Find(MASP); GioHangHoa gio = (GioHangHoa)Session["cart"]; if (gio == null) { gio = new GioHangHoa(); } HangHoaBan hangHoa = new HangHoaBan(MASP, 1); hangHoa.name = sp.TENSP; hangHoa.price = sp.GIASP; hangHoa.link_anh = sp.LINK_ANH; gio.addHangHoa(hangHoa); Session["cart"] = gio; return(Redirect("~/Shopping/Index")); }