static void Main(string[] args)
        {
            var purchaseRequirements = new TestData().Create();
            var purchaseOptimizer    = new PurchaseOptimizer();

            var productPurchaseOrders = purchaseOptimizer.Optimize(purchaseRequirements);

            foreach (var productPurchaseOrder in productPurchaseOrders)
            {
                Console.WriteLine("Product: " + productPurchaseOrder.Product.Name);
                if (productPurchaseOrder.PurchaseOrders.Any())
                {
                    foreach (var order in productPurchaseOrder.PurchaseOrders)
                    {
                        Console.WriteLine("     Supplier: " + order.Supplier.Name + " | Qty: " + order.Quantity + " | Cost: " + order.TotalCost.ToString("C"));
                    }
                }
                else
                {
                    Console.WriteLine("     No Supplier Stock");
                }

                Console.WriteLine("Total Cost : " + productPurchaseOrder.TotalCost.ToString("C"));
                Console.WriteLine("==============================================");
            }

            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            //PreMute();
            var purchaseRequirements = new TestData().Create();
            var purchaseOptimizer    = new PurchaseOptimizer();

            purchaseOptimizer.Optimize(purchaseRequirements);
        }
Пример #3
0
        static void Main(string[] args)
        {
            // Create Purchase Requirements from test data
            TestData testData             = new TestData();
            var      purchaseRequirements = testData.Create();

            // Initialize Optimizer - Object to be implemented
            IPurchaseOptimizer purchaseOptimizer = new PurchaseOptimizer(testData.Suppliers);

            // Optimize - Calculates the optimal set of suppliers to purchase products from
            var purchaseOrders = purchaseOptimizer.Optimize(purchaseRequirements);

            WriteToConsole(purchaseOrders);
        }
Пример #4
0
        static void Main(string[] args)
        {
            var purchaseRequirements = new TestData().Create();
            var purchaseOptimizer    = new PurchaseOptimizer();

            purchaseOptimizer.Optimize(purchaseRequirements);

            var supplierResult = purchaseOptimizer.supplierResult;
            var purchaseRequirementsPending = purchaseOptimizer.purchaseRequirementsPending;

            Console.WriteLine("Retrieved mapped data");
            var jsonMapped = JsonSerializer.Serialize(supplierResult);

            Console.WriteLine(jsonMapped);


            Console.WriteLine("Unmapped data");
            foreach (var i in purchaseRequirementsPending)
            {
                Console.WriteLine($"ProductName:{i.Product.Name}, QuantityLeft:{i.Quantity}");
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            // Our data store
            var purchaseRequirements = new TestData().Create();

            // Dependencies at top of composition root
            var supplierService = new SupplierService();
            var supplierShippingCostCalculator  = new SupplierShippingCostCalculator();
            var stockCalculatorService          = new StockCalculatorService();
            var purchaseOrderFulfillmentService = new PurchaseOrderFulfillmentService(stockCalculatorService);

            var productFulfillmentService     = new ProductFulfillmentService(supplierService, supplierShippingCostCalculator, purchaseOrderFulfillmentService);
            var serviceTypeFulfillmentService = new ServiceTypeFulfillmentService();

            // Optimize and generate purchase orders for suppliers to fulfill
            var purchaseOptimizer = new PurchaseOptimizer(new List <IFulfillmentService>()
            {
                serviceTypeFulfillmentService, productFulfillmentService
            });

            purchaseOptimizer.Optimize(purchaseRequirements);

            Console.Read();
        }