public void RemoveOne(Solder solder, int quantity) { CartLine line = Lines.Where(s => s.Solder.Id == solder.Id).FirstOrDefault(); if (line != null) { line.Quantity -= quantity; } if (line.Quantity == 0) { RemoveItem(line.Solder); } }
public void AddItem(Solder solder, int quantity) { CartLine line = Lines.Where(s => s.Solder.Id == solder.Id).FirstOrDefault(); if (line == null) { Lines.Add(new CartLine { Solder = solder, Quantity = quantity }); } else { line.Quantity += quantity; } }
public void RemoveItem(Solder solder) { Lines.RemoveAll(s => s.Solder.Id == solder.Id); }