public void UpdateItem(Sweet sweet, int quantity) { CartLine line = lineCollection .Where(s => s.Sweet.SweetId == sweet.SweetId) .FirstOrDefault(); if (line != null) { line.Quantity = quantity; } }
public void AddItem(Sweet sweet, int quantity) { CartLine line = lineCollection .Where(s => s.Sweet.SweetId == sweet.SweetId) .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.SweetId == sweet.SweetId); }