コード例 #1
0
ファイル: OrderForm.cs プロジェクト: alexgrbach/Projects
 private static void DrawProductInformation(CustomerOrder order)
 {
     var productsManager = new ProductManager();
     var productsResponse = productsManager.GetProductResponse(order.ProductKey);
     Console.WriteLine($"Material cost per SqFt: {productsResponse.Product.MaterialCostSqFt:C}");
     Console.WriteLine($"Labor cost per SqFt: {productsResponse.Product.LaborCostSqFt:C}");
 }
コード例 #2
0
        public void OrderCalculationsTest()
        {
            var orderManager = new OrderManager();
            CustomerOrder testOrder = new CustomerOrder();
            StateManager stateManager = new StateManager();
            ProductManager productManager = new ProductManager();

            testOrder = orderManager.OrderCalculations(_order);
            var productResponse = productManager.GetProductResponse(_order.ProductKey);
            var laborCost = productResponse.Product.LaborCostSqFt;
            var materialCost = productResponse.Product.MaterialCostSqFt;
            var stateResponse = stateManager.GetStateResponse(_order.StateKey);

            var subTotal = (_order.Area * (materialCost + laborCost));
            var tax = subTotal/stateResponse.State.TaxRate;
            var total = subTotal + tax;

            Assert.AreEqual(total, testOrder.OrderTotal);
        }
コード例 #3
0
ファイル: Prompts.cs プロジェクト: alexgrbach/Projects
        /// <summary>
        /// Prompts the user for a product and adds it to an order
        /// </summary>
        /// <param name="order">Order that is to be updated </param>
        /// <param name="headerText">Text that is to be displayed on the header</param>
        /// <returns>Updated customer order</returns>
        public CustomerOrder GetProductFromCustomer(CustomerOrder order)
        {
            Console.Clear();
            _orderForm.AddOrder(order, _headerText);
            Console.WriteLine();
            _displayFullList.Products();
            Console.WriteLine();

            var ops = new ProductManager();
            ProductResponse response;
            string input;
            do
            {
                Console.Write("Please enter a product: ");
                input = Console.ReadLine();

                if (string.IsNullOrEmpty(input) && _edit)
                {
                    return order;
                }

                if (!string.IsNullOrWhiteSpace(input))
                {
                    //Formating to match key
                    input = (input.ToUpper().First() + input.Substring(1).ToLower());
                }

                response = ops.GetProductResponse(input);

                if (!response.Success)
                {
                    Console.Clear();
                    _orderForm.AddOrder(order, _headerText);
                    Console.WriteLine();
                    _displayFullList.Products();
                    Console.WriteLine();
                    Console.WriteLine(response.Message);
                }
            } while (!response.Success);

            order.ProductKey = input;
            return order;
        }
コード例 #4
0
ファイル: OrderManager.cs プロジェクト: alexgrbach/Projects
        /// <summary>
        /// Calculates parts of the Customer Order
        /// </summary>
        /// <param name="order">Order that the calcualtions are to be preformed on.</param>
        /// <returns>Updated order.</returns>
        public CustomerOrder OrderCalculations(CustomerOrder order)
        {
            var stateManager = new StateManager();
            var stateResponse = stateManager.GetStateResponse(order.StateKey);

            var productManager = new ProductManager();
            var productRepsonse = productManager.GetProductResponse(order.ProductKey);

            order.Area = decimal.Parse(order.AreaString);
            order.MaterialCostTotal = order.Area*productRepsonse.Product.MaterialCostSqFt;
            order.LaborCostTotal = order.Area*productRepsonse.Product.LaborCostSqFt;
            decimal subTotal = order.MaterialCostTotal + order.LaborCostTotal;
            order.OrderTax = subTotal/stateResponse.State.TaxRate;
            order.OrderTotal = subTotal + order.OrderTax;

            return order;
        }