private PickList PickProduct( Guid orderId, Product product, int quantity, Warehouse warehouse) { return new PickList { OrderId = orderId, Product = product, Quantity = quantity, Warehouse = warehouse }; }
private Warehouse LocateProduct( Product product, int quantity) { var inventoryLevels = from warehouse in _warehouseRepository.GetAll() select new { Warehouse = warehouse, QuantityAllocated = (int ?)warehouse.PickLists .Where(p => p.Product.Id == product.Id) .Sum(p => p.Quantity) ?? 0, QuantityRestocked = (int ?)warehouse.Requisitions .Where(r => r.Product.Id == product.Id) .Where(r => r.Restocks.Any()) .Sum(r => r.Quantity) ?? 0 }; return inventoryLevels .Where(l => l.QuantityRestocked - l.QuantityAllocated >= quantity) .Select(l => l.Warehouse) .FirstOrDefault(); }
public void Initialize() { _warehouses = new FakeRepository<Warehouse>(); _warehouse1 = new Warehouse { Name = "Hanger 18" }; _procrit = new Product { Id = 11190 }; _warehouse1.Requisitions = new List<Requisition>(); _warehouse1.Requisitions.Add(new Requisition { Product = _procrit, Quantity = 7, Restocks = new List<Restock> { new Restock() } }); _warehouse1.PickLists = new List<PickList>(); _warehouses.Add(_warehouse1); _clinic = new Customer { Name = "The Clinic", ShippingAddress = "1 My Way" }; _service = new InventoryAllocationService(_warehouses); }