public void AddItem(int quantity, decimal price, Item item, Storehouse storehouse) { var invoiceItem = InvoiceItem.Create(quantity, price, item, this, storehouse); var itemToUpdate = this.InvoiceItems.FirstOrDefault(x => x.Equals(invoiceItem)); this.UpdateInvoiceItems(invoiceItem); this.UpdateSums(); }
public void AddToStorehouse(Storehouse storehouse, int quantity) { var storehouseItem = StorehouseItem.Create(this.Quantity, storehouse.Id, this.Id, this.Price); var storehouseItemToUpdate = this.StorehouseItems.FirstOrDefault(x => x.Equals(storehouseItem)); if (storehouseItemToUpdate == null) { this.StorehouseItems.Add(storehouseItem); } else { storehouseItemToUpdate.AddQiantity(this.Quantity); } }
public static InvoiceItem Create( int quantity, decimal price, Item item, Invoice invoice, Storehouse storehouse = null) { var invoiceItem = new InvoiceItem() { Quantity = quantity, Price = price, ItemId = item.Id, InvoiceId = invoice.Id, StorehouseItems = new HashSet <StorehouseItem>() }; if (storehouse != null) { invoiceItem.AddToStorehouse(storehouse, invoiceItem.Quantity); } return(invoiceItem); }
public void AddItem(Dictionary <Storehouse, int> quantities, decimal price, Item item, Storehouse storehouse) { var invoiceItem = InvoiceItem.Create(quantities, price, item, this); this.UpdateInvoiceItems(invoiceItem); this.UpdateSums(); }
public Storehouse CreateStorehouse(string name) { return(Storehouse.Create(name, this.Id)); }