public void UpdateItem(SanPham product, int quantity) { var line = lineCollection.FirstOrDefault(x => x.Product.Id == product.Id); if (line != null) { line.Quantity = quantity; } }
public void AddItem(SanPham product, int quantity) { var line = lineCollection.FirstOrDefault(x => x.Product.Id == product.Id); if (line != null) { line.Quantity += quantity; } else { lineCollection.Add(new CartLine { Product = product, Quantity = quantity }); } }
public void RemoveLine(SanPham product) { lineCollection.RemoveAll(p => p.Product.Id == product.Id); }