public void AddItem(Sweet sweet, int quantity) { CartLine line = lineCollection .Where(s => s.Sweet.Id == sweet.Id) .FirstOrDefault(); if (line == null) { lineCollection.Add(new CartLine { Sweet = sweet, Quantity = quantity }); } else { line.Quantity += quantity; } }
public void RemoveLine(Sweet sweet) { lineCollection.RemoveAll(l => l.Sweet.Id == sweet.Id); }