Exemple #1
0
        public ShippingController(IConfiguration config)
        {
            var connString  = config.GetValue <string>("connString");
            var lic         = config.GetValue <string>("fedExLicense");
            var orderRepo   = new OrderRepo(connString);
            var productRepo = new ProductRepo(connString);
            var custRepo    = new CustomerRepo(connString);
            var paySvc      = new PaymentService();
            var shipSvc     = new FedExShipper(new FedEx.FedExService(lic));

            _orderService = new OrderService(orderRepo, productRepo, custRepo, paySvc, shipSvc);
        }
Exemple #2
0
        public string CalculateOrder(int customerId)
        {
            var connString   = _config.GetValue <string>("connString");
            var lic          = _config.GetValue <string>("fedExLicense");
            var orderRepo    = new OrderRepo(connString);
            var productRepo  = new ProductRepo(connString);
            var custRepo     = new CustomerRepo(connString);
            var paySvc       = new PaymentService();
            var shipSvc      = new FedExShipper(new FedEx.FedExService(lic));
            var orderService = new OrderService(orderRepo, productRepo, custRepo, paySvc, shipSvc);

            // The "Entry Point" uses the Service to Command or Query
            OrderModel result = orderService.CalculateOrder(customerId, new List <int>());

            var lawl = orderService.CreateOrder(result.OrderId, new PaymentInfoModel());

            // Output for fun:
            return(string.Format("Order Total: ${0}, Order Created: {1}", result.NetTotal, lawl));
        }