public void AddItem(Gadget gadget, int quantity) { CartLine line = lineCollection .Where(p => p.Gadget.GadgetId == gadget.GadgetId) .FirstOrDefault(); if (line == null) { lineCollection.Add(new CartLine { Gadget = gadget, Quantity = quantity }); } else { line.Quantity += quantity; } }
public void RemoveLine(Gadget gadget) { lineCollection.RemoveAll(l => l.Gadget.GadgetId == gadget.GadgetId); }