Пример #1
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");
            }
        }
Пример #2
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");
            }
        }
Пример #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);
        }