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

            if (pl != null)
            {
                pl.Quantity -= 1;
            }
        }
Ejemplo n.º 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;
            }
        }