Пример #1
0
        private bool HandlePurchase(IInventoryItem item)
        {
            LiveSupplier usedSupplier = GetSupplierForPurchase(item);

            usedSupplier.ModifyStockValue(item.Name, item.Category, -1);
            Database.ModifyStockValue(item.Name, item.Category, -1);
            return(true);
        }
Пример #2
0
        private LiveSupplier GetSupplierForPurchase(IInventoryItem item)
        {
            LiveSupplier suplier = Supliers.Single(s => s.Name.Equals(item.PreferredSupplier.Name));

            if (suplier.HasStock(item.Name, item.Category))
            {
                return(suplier);
            }

            suplier = Supliers.Single(s => s.Name.Equals(item.FailoverSupplier.Name));
            if (suplier.HasStock(item.Name, item.Category))
            {
                return(suplier);
            }

            return(Supliers.FirstOrDefault(s => s.HasStock(item.Name, item.Category)));
        }