Beispiel #1
0
        // GET api/status/{warehouseId}
        public InboundOrderResponse Get(int warehouseId)
        {
            log.Info("orderIn for warehouseId: " + warehouseId);

            var operationsManager = new Employee(employeeRepository.GetOperationsManager(warehouseId));

            log.Debug(String.Format("Found operations manager: {0}", operationsManager));

            var LowStock = stockRepository.GetAllStockThatNeedRestocking(warehouseId);

            Dictionary <Company, List <InboundOrderLine> > orderlinesByCompany = new Dictionary <Company, List <InboundOrderLine> >();

            for (int i = 0; i < LowStock.Count; i++)
            {
                RestockingDataModel stock   = LowStock[i];
                Company             company = CreateCompanyDataModelNeededForOrder(stock);

                if (!orderlinesByCompany.ContainsKey(company))
                {
                    orderlinesByCompany.Add(company, new List <InboundOrderLine>());
                }

                CreateOrder(orderlinesByCompany, stock, company);
            }
            ;

            log.Debug(String.Format("Constructed order lines: {0}", orderlinesByCompany));

            var orderSegments = Sort(orderlinesByCompany);

            log.Info("Constructed inbound order");

            // return the order with right informaton
            return(CreateOrderResponse(warehouseId, operationsManager, orderSegments));
        }
Beispiel #2
0
        private static Company CreateCompanyDataModelNeededForOrder(RestockingDataModel stock)
        {
            Company company = new Company();

            company.Gcp   = stock.CompanyID;
            company.Name  = stock.CompanyName;
            company.Addr2 = stock.Addr2;
            company.Addr3 = stock.Addr3;
            company.Addr4 = stock.Addr4;

            company.PostalCode = stock.Postcode;
            company.City       = stock.City;
            company.Tel        = stock.Phone;
            company.Mail       = stock.Mail;
            return(company);
        }
Beispiel #3
0
        private static void CreateOrder(Dictionary <Company, List <InboundOrderLine> > orderlinesByCompany, RestockingDataModel stock, Company company)
        {
            // decide how many items to order
            var orderQuantity = Math.Max(stock.LowerThreshold * 3 - stock.Held, stock.MinimumOrderQuantity);

            //put a new order in the dict
            orderlinesByCompany[company].Add(
                new InboundOrderLine()
            {
                gtin     = stock.ProductNumber,
                name     = stock.ProductName,
                quantity = orderQuantity
            });
        }