Пример #1
0
        /// <summary>
        /// Displays all states in the list
        /// </summary>
        public void States()
        {
            const string headFormat = "{0, 2} = {1,-10}";

            var statesManager = new StateManager();
            Console.WriteLine("Current service area");
            Console.WriteLine("====================");

            foreach (var state in statesManager.GetAllStates())
            {
                Console.WriteLine(headFormat, state.StateAbbreviation, state.StateName);
            }
        }
Пример #2
0
 private void DrawTotalInformation(CustomerOrder order)
 {
     var statesManager = new StateManager();
     var stateResponse = statesManager.GetStateResponse(order.StateKey);
     Console.WriteLine(_lines.DrawLine(LineTypes.Equals));
     Console.WriteLine();
     Console.WriteLine($"Total Material Cost: {order.MaterialCostTotal:C}");
     Console.WriteLine($"Total Labor Cost: {order.LaborCostTotal:C}");
     Console.WriteLine($"Subtotal: {(order.MaterialCostTotal + order.LaborCostTotal):C}");
     Console.WriteLine($"{stateResponse.State.StateName}'s tax rate is {stateResponse.State.TaxRate}%");
     Console.WriteLine($"Tax: {order.OrderTax:C}");
     Console.WriteLine(_lines.DrawLine(LineTypes.Equals));
     Console.WriteLine();
     Console.WriteLine($"Order Total: {order.OrderTotal:C}");
 }
Пример #3
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);
        }
Пример #4
0
        /// <summary>
        /// Prompts the user for a state 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 GetStateFromCustomer(CustomerOrder order)
        {
            string input;
            Console.Clear();
            _orderForm.AddOrder(order, _headerText);
            Console.WriteLine();
            _displayFullList.States();
            Console.WriteLine();

            var ops = new StateManager();
            StateResponse response;

            do
            {
                Console.Write("Please enter customers state abbrevation: ");
                input = Console.ReadLine().ToUpper();
                if (string.IsNullOrEmpty(input) && _edit)
                {
                    return order;
                }
                response = ops.GetStateResponse(input);
                if (!response.Success)
                {
                    Console.Clear();
                    _orderForm.AddOrder(order, _headerText);
                    Console.WriteLine();
                    _displayFullList.States();
                    Console.WriteLine();
                    Console.WriteLine(response.Message);
                }
            } while (!response.Success);

            order.StateKey = input;
            return order;
        }
Пример #5
0
        /// <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;
        }