Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
 public Storehouse CreateStorehouse(string name)
 {
     return(Storehouse.Create(name, this.Id));
 }