예제 #1
0
        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;
            }
        }
예제 #2
0
 public void RemoveLine(Gadget gadget)
 {
     lineCollection.RemoveAll(l => l.Gadget.GadgetId == gadget.GadgetId);
 }