public void AddItem(Product product, int quantity) { Cartline line = lineCollection .Where(p => p.Product.ID == product.ID) .FirstOrDefault(); if (line == null) { lineCollection.Add(new Cartline { Product = product, Quantity = quantity}); } else { line.Quantity += quantity; } }
public void RemoveLine(Product product) { lineCollection.RemoveAll(l => l.Product.ID == product.ID); }