public void CanEditOrder(DateTime orderDate, int orderNumber, string newCustomerName, string newState, string newProductType, decimal newArea, bool expected) { OrderManager orderManager = OrderManagerFactory.create(orderDate); TaxManager taxManager = TaxManagerFactory.create(); DisplayTaxResponse taxResponse = taxManager.DisplayTaxResponse(newState); ProductManager productManager = ProductManagerFactory.create(); DisplayProductResponse productResponse = productManager.DisplayProductResponse(newProductType); Orders order = new Orders() { Area = newArea, CostPerSquareFoot = productResponse.Products.CostPerSquareFoot, CustomerName = newCustomerName, LaborCostPerSquareFoot = productResponse.Products.LaborCostPerSquareFoot, OrderNumber = orderNumber, ProductType = productResponse.Products.ProductType, State = taxResponse.Tax.StateAbbreviation, TaxRate = taxResponse.Tax.TaxRate, }; EditOrderResponse orderResponse = orderManager.EditOrder(order); Assert.AreEqual(orderResponse.Success, expected); }
public void CanLookupAccount(DateTime orderDate, bool expected) { OrderManager orderManager = OrderManagerFactory.create(orderDate); DisplayOrderResponse response = orderManager.LookupOrder(); Assert.AreEqual(expected, response.Success); }
public void CanRemoveOrder(DateTime orderDate, int orderNumber, bool expected) { OrderManager orderManager = OrderManagerFactory.create(orderDate); Orders order = orderManager.GetOrder(orderNumber); RemoveOrderResponse removeResponse = orderManager.RemoveOrder(order); Assert.AreEqual(removeResponse.Success, expected); }
public void CanGetOrder(DateTime orderDate, int orderNumber, string customerName, string state, string productType, decimal area) { OrderManager orderManager = OrderManagerFactory.create(orderDate); Orders order = orderManager.GetOrder(orderNumber); Assert.AreEqual(order.CustomerName, customerName); Assert.AreEqual(order.State, state); Assert.AreEqual(order.ProductType, productType); Assert.AreEqual(order.Area, area); }
public void Execute() { ConsoleIO.ShowChoice("3. Remove Order"); DateTime orderDate; OrderManager orderManager; while (true) { orderDate = ConsoleIO.inputDate("Enter order date (MMddyyyy): "); orderManager = OrderManagerFactory.create(orderDate); if (!orderManager.IfFileExist()) { Console.WriteLine("No order in this date!"); continue; } else { break; } } Orders order; while (true) { int orderNumber = ConsoleIO.inputInt("Enter order number: ", false); order = orderManager.GetOrder(orderNumber); if (order is null) { continue; } break; } ConsoleIO.DisplayOrderDetail(order); Console.Write("Are you sure want to remove?(Y/N): "); string result = Console.ReadLine(); if (result.ToUpper() == "Y") { RemoveOrderResponse removeResponse = orderManager.RemoveOrder(order); if (removeResponse.Success) { Console.WriteLine("Order removed successful."); } else { Console.WriteLine("An error occurred: "); Console.WriteLine(removeResponse.Message); } Console.WriteLine("\nPress any key to continue..."); Console.ReadKey(); } }
public void Execute() { ConsoleIO.ShowChoice("1. Order Lookup"); DateTime orderDate; OrderManager orderManager; while (true) { orderDate = ConsoleIO.inputDate("Enter order date (MMddyyyy): "); orderManager = OrderManagerFactory.create(orderDate); if (!orderManager.IfFileExist()) { Console.WriteLine("No order in this date!"); continue; } else { break; } } DisplayOrderResponse response = orderManager.LookupOrder(); if (response.Success) { for (int i = 0; i < response.orders.Count; i++) { ConsoleIO.DisplayOrderDetail(response.orders[i]); } } else { Console.WriteLine("An error occurred: "); Console.WriteLine(response.Message); } Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
public void Execute() { ConsoleIO.ShowChoice("2. Edit Order"); DateTime orderDate; OrderManager orderManager; while (true) { orderDate = ConsoleIO.inputDate("Enter order date (MMddyyyy): "); orderManager = OrderManagerFactory.create(orderDate); if (!orderManager.IfFileExist()) { Console.WriteLine("No order in this date!"); continue; } else { break; } } Orders order; while (true) { int orderNumber = ConsoleIO.inputInt("Enter order number: ", false); order = orderManager.GetOrder(orderNumber); if (order is null) { continue; } break; } string customerName = ConsoleIO.inputName($"Enter customer name({order.CustomerName}): ", true); if ((customerName + "").Trim() == "") { customerName = order.CustomerName; } DisplayTaxResponse taxResponse; while (true) { Console.Write($"Enter state({order.State}): "); string state = Console.ReadLine(); if ((state + "").Trim() == "") { state = order.State; } TaxManager taxManager = TaxManagerFactory.create(); taxResponse = taxManager.DisplayTaxResponse(state.ToUpper()); if (!taxResponse.Success) { Console.WriteLine("An error occurred: "); Console.WriteLine(taxResponse.Message); } else { break; } } DisplayProductResponse productResponse; while (true) { Console.Write($"Enter product type({order.ProductType}): "); string productType = Console.ReadLine(); if ((productType + "").Trim() == "") { productType = order.ProductType; } ProductManager productManager = ProductManagerFactory.create(); productResponse = productManager.DisplayProductResponse(productType); if (!productResponse.Success) { Console.WriteLine("An error occurred: "); Console.WriteLine(productResponse.Message); } else { break; } } decimal area = ConsoleIO.inputInt($"Enter product type({order.Area}): ", true); if (area == -1) { area = order.Area; } order = new Orders() { Area = area, CostPerSquareFoot = productResponse.Products.CostPerSquareFoot, CustomerName = customerName, LaborCostPerSquareFoot = productResponse.Products.LaborCostPerSquareFoot, OrderNumber = order.OrderNumber, ProductType = productResponse.Products.ProductType, State = taxResponse.Tax.StateAbbreviation, TaxRate = taxResponse.Tax.TaxRate, }; ConsoleIO.ShowSummary(); ConsoleIO.DisplayOrderDetail(order); string result; while (true) { Console.Write("Do you want to save the order?(Y/N): "); result = Console.ReadLine(); if (result.ToUpper() == "Y" || result.ToUpper() == "N") { break; } else { Console.Write("Invalid input."); } } if (result.ToUpper() == "N") { return; } EditOrderResponse orderResponse = orderManager.EditOrder(order); if (orderResponse.Success) { Console.WriteLine("Order edited successfully."); } else { Console.WriteLine("An error occurred: "); Console.WriteLine(orderResponse.Message); } Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
public void Execute() { ConsoleIO.ShowChoice("1. Add Order"); DateTime orderDate = ConsoleIO.inputDate("Enter order date (MMddyyyy): "); string customerName = ConsoleIO.inputName("Enter customer name: ", false); DisplayTaxResponse taxResponse; while (true) { string state = ConsoleIO.inputString("Enter state: "); TaxManager taxManager = TaxManagerFactory.create(); taxResponse = taxManager.DisplayTaxResponse(state); if (!taxResponse.Success) { Console.WriteLine("An error occurred: "); Console.WriteLine(taxResponse.Message); } else { break; } } DisplayProductResponse productResponse; while (true) { string productType = ConsoleIO.inputString("Enter product type: "); ProductManager productManager = ProductManagerFactory.create(); productResponse = productManager.DisplayProductResponse(productType); if (!productResponse.Success) { Console.WriteLine("An error occurred: "); Console.WriteLine(productResponse.Message); } else { break; } } decimal area = ConsoleIO.inputInt("Enter area: ", false); OrderManager orderManager = OrderManagerFactory.create(orderDate); Orders order = new Orders() { Area = area, CostPerSquareFoot = productResponse.Products.CostPerSquareFoot, CustomerName = customerName, LaborCostPerSquareFoot = productResponse.Products.LaborCostPerSquareFoot, OrderNumber = orderManager.GenerateOrderNumber(), ProductType = productResponse.Products.ProductType, State = taxResponse.Tax.StateAbbreviation, TaxRate = taxResponse.Tax.TaxRate, }; ConsoleIO.ShowSummary(); ConsoleIO.DisplayOrderDetail(order); string result; while (true) { Console.Write("Do you want to place the order?(Y/N): "); result = Console.ReadLine(); if (result.ToUpper() == "Y" || result.ToUpper() == "N") { break; } else { Console.Write("Invalid input."); } } if (result.ToUpper() == "N") { return; } AddOrderResponse orderResponse = orderManager.AddOrder(order); if (orderResponse.Success) { Console.WriteLine("order saved successfully."); } else { Console.WriteLine("An error occurred: "); Console.WriteLine(orderResponse.Message); } Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }