public CT_GIOHANG(string MaSP) { this.MaSP = MaSP; SANPHAM sp = LaySanPham(); this.TenSP = sp.TenSP; this.DonGia = sp.GiaBan ?? 0; }
public CHITIETDONHANG(string MaSP) { this.MaSP = MaSP; SANPHAM sanPham = LaySanPham(MaSP); DonGia = sanPham.GiaBan; TenSP = sanPham.TenSP; }
public void AddToCart(SANPHAM sanPham) { var cartItem = db.CARTs1.SingleOrDefault(c => c.CartId == ShoppingCartId && c.MaSP == sanPham.MaSP); if (cartItem == null) { cartItem = new Cart1 { MaSP = sanPham.MaSP, CartId = ShoppingCartId, Count = 1, NgayTao = DateTime.Now }; db.CARTs1.Add(cartItem); } else { cartItem.Count++; } db.SaveChanges(); }
public SANPHAM LaySanPham() { SANPHAM sanPham = db.SANPHAMs.SingleOrDefault(p => p.MaSP == MaSP); return(sanPham); }