Esempio n. 1
0
        // Removes inventory from stock
        public void RemoveInventory(Inventory inventory)
        {
            InventoryAmount curr = InventoryAmountList.Find(x => x.Inventory.Equals(inventory));

            if (curr != null)
            {
                InventoryAmountList.Remove(curr);
            }
            else
            {
                throw new Exception("No inventory found");
            }
        }
Esempio n. 2
0
        // Removes inventory with given amount, if given amount is bigger than current amount - throw exception
        public void RemoveInventory(Inventory inventory, int amount)
        {
            InventoryAmount curr = InventoryAmountList.Find(x => x.Inventory.Equals(inventory));

            if (curr.Amount > amount)
            {
                curr.Amount -= amount;
            }
            else
            {
                throw new Exception($"Not enough amount in stock");
            }
        }
Esempio n. 3
0
        // Get amount of given inventory in stock. If the `inventory` is not found, return 0.
        public int GetInventoryAmount(Inventory inventory)
        {
            InventoryAmount curr = InventoryAmountList.Find(x => x.Inventory.Equals(inventory));

            return(curr != null ? curr.Amount : 0);
        }
Esempio n. 4
0
 public InventoryAmountOrSoldAmount( InventoryAmount ia => this.InventoryAmount = ia;