Exemple #1
0
 public void AddLine(Product product, int quantity)
 {
     if (CartLines.Where(cl => cl.Product == product).Count() != 0)
     {
         CartLine cl = CartLines.Where(x => x.Product.Equals(product)).FirstOrDefault();
         cl.Quantity += quantity;
     }
     else
     {
         _lines.Add(new CartLine()
         {
             Product  = product,
             Quantity = quantity
         });
     }
 }
        /// <summary>
        /// Sepete ürün ve adet bilgisini ekleme
        /// </summary>
        /// <param name="product"></param>
        /// <param name="quantity"></param>
        public void AddItem(IProduct product, int quantity)
        {
            var cardLines = CartLines.Where(x => x.Product == product).ToList();

            if (cardLines != null && cardLines.Count() > 0)
            {
                cardLines.First().Quantity += quantity;
            }
            else
            {
                CartLines.Add(new CartLine()
                {
                    Product  = product,
                    Quantity = quantity
                });
            }

            this.TotalPrice = this.OriginalCartPrice;
        }