示例#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");
            }
        }
示例#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");
            }
        }
示例#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);
        }
示例#4
0
 // Adds inventory to Stock with given amount. Default amount 1
 public void AddInventory(Inventory inventory, int amount = 1)
 {
     InventoryAmountList.Add(new InventoryAmount(inventory, amount));
 }