示例#1
0
文件: Invoice.cs 项目: ramyothman/RBM
        /// <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);
            }
        }
示例#2
0
 public InvoiceItem(string invoiceId, Product product, int quantity)
 {
     this.InvoiceId = invoiceId;
     this.InvoiceItemProduct = product;
     this.Quantity = quantity;
 }