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}"); }
/// <summary> /// Displays all Products in list /// </summary> public void Products() { string line = _lines.DrawLine(LineTypes.Equals); const string sectionHead = "Current Products"; const string headFormat = "{0,-10}{1, 8:C}{2,-20}"; var productsManager = new ProductManager(); Console.WriteLine(); Console.WriteLine(sectionHead.PadLeft((line.Length / 2 + sectionHead.Length / 2) + 1, ' ')); Console.WriteLine(line); foreach (var product in productsManager.GetAllProduct()) { Console.WriteLine(headFormat, product.ProductName, product.LaborCostSqFt + product.MaterialCostSqFt, "/SqFt Installed"); //Console.WriteLine($"{product.ProductName}\t\t{(product.LaborCostSqFt + product.MaterialCostSqFt):C}/SqFt installed."); } }
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); }
/// <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; }
/// <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; }