Exemple #1
0
        /// <summary>
        /// Adding another item to the cart (may be one there already - dont know)
        /// </summary>
        /// <param name="productId"></param>
        /// <param name="qty"></param>
        public void AddToInvoice(Product product, int qty)
        {
            bool foundInvoiceItem = false;
            int productId = product.ProductId;
            foreach (InvoiceItem x in _invoiceItems)
            {
                if (x.ProductId == productId)
                {
                    x.Quantity += qty;
                    if (x.Quantity <= 0)
                    {
                        RemoveProduct(productId);
                    }
                    foundInvoiceItem = true;
                    break;
                }
            }

            if (!foundInvoiceItem && qty > 0)
            {
                InvoiceItem invItem = new InvoiceItem(this.InvoiceId, product, qty);
                _invoiceItems.Add(invItem);
            }
        }
Exemple #2
0
 public InvoiceItem(string invoiceId, Product product, int quantity)
 {
     this.InvoiceId = invoiceId;
     this.InvoiceItemProduct = product;
     this.Quantity = quantity;
 }