Exemple #1
0
        public void ReduceAmount(int id)
        {
            ProductLine pl = lineCollection.Where(l => l.Product.Id == id).FirstOrDefault();

            if (pl != null)
            {
                pl.Quantity -= 1;
            }
        }
Exemple #2
0
        public void AddItem(Product prod, int quantity)
        {
            ProductLine line = lineCollection
                               .Where(g => g.Product.Id == prod.Id)
                               .FirstOrDefault();

            if (line == null)
            {
                lineCollection.Add(new ProductLine
                {
                    Product  = prod,
                    Quantity = quantity
                });
            }
            else
            {
                line.Quantity += quantity;
            }
        }