public void ReduceAmount(int id) { ProductLine pl = lineCollection.Where(l => l.Product.Id == id).FirstOrDefault(); if (pl != null) { pl.Quantity -= 1; } }
public void AddItem(Product prod, int quantity) { ProductLine line = lineCollection .Where(g => g.Product.Id == prod.Id) .FirstOrDefault(); if (line == null) { lineCollection.Add(new ProductLine { Product = prod, Quantity = quantity }); } else { line.Quantity += quantity; } }