public void Execute() { OrderManager manager = OrderManagerFactory.Create(); IUserIO io = new ConsoleIO(); //This can be replaced with a factory if we ever use multiple IO types io.Clear(); io.WriteLine("Order Removal"); io.WriteLine(new string('*', 27)); DateTime targetDate = io.GetDate("Enter the date of the order to remove: ").Date; int targetNum = io.GetInt("Enter the order number to remove: "); string result = ""; if (manager.TryGetOrder(targetNum, targetDate, out Order target)) { io.Clear(); io.WriteLine("Search result:"); io.WriteLine(target.GetFullOrderString()); bool confirm = io.GetBool("Are you sure you would like to delete this order?"); if (confirm) { result = manager.DeleteOrder(target); } else { result = "Removal cancelled."; } } else { result = "No order found with given parameters. Returning to menu."; } io.WriteLine(result); io.WaitForUser("Press any key to continue..."); }
public void Execute() { Manager manager = ManagerFactory.Create(); ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Display Orders"); ConsoleIO.SeperatorBar(); DateTime orderDate = ConsoleIO.RetrieveOrderDateFromUser("Enter an order date (Format: MM/DD/YYYY): "); DisplayOrdersResponse response = manager.DisplayOrders(orderDate); if (response.Success) { ConsoleIO.Clear(); ConsoleIO.GeneralPrompt($"Orders currently in system ({orderDate.ToString()}): "); ConsoleIO.SeperatorBar(); ConsoleIO.BlankLine(); ConsoleIO.DisplayListOfOrders(response.Orders); } else { ConsoleIO.GeneralPrompt("An error occurred."); Console.WriteLine(response.Message); } ConsoleIO.ReadKeyPlusPrompt("Press any key to continue..."); }
public void Execute() { OrderManager manager = OrderManagerFactory.Create(); IUserIO io = new ConsoleIO(); io.Clear(); io.WriteLine("Order Creation Form"); io.WriteLine(new string('*', 27)); DateTime date = GetFutureDate(io); string name = GetCustomerName(io); State state = io.GetState("Enter the desired state:", manager.GetStates()); Product product = io.PickProduct(manager.GetProducts()); decimal area = io.GetArea("Enter the area for the order"); Order newOrder = manager.ValidateNewOrder(new Order(date, name, state, product, area)); io.WriteLine(newOrder.GetFullOrderString()); bool confirm = io.GetBool("Are you sure you would like to place this order?"); if (confirm) { manager.SaveValidOrder(newOrder); io.WriteLine("Order placed!"); } else { io.WriteLine("Order cancelled."); } io.WaitForUser("Press any key to continue..."); }
public void Execute() { OrderManager manager = OrderManagerFactory.Create(); IUserIO io = new ConsoleIO(); //This can be replaced with a factory if we ever use multiple IO types io.Clear(); io.WriteLine("Order Editing"); io.WriteLine(new string('*', 27)); DateTime targetDate = io.GetDate("Enter the date of the order to edit: ").Date; int targetNum = io.GetInt("Enter the order number to edit: "); string result = ""; if (manager.TryGetOrder(targetNum, targetDate, out Order target)) { Order pendingChanges = target; io.Clear(); io.WriteLine("Search result:"); io.WriteLine(target.GetFullOrderString()); //TODO: Clean this WAYYYYYYYY up. pendingChanges = MakeEdits(io, target, manager); io.WriteLine(pendingChanges.GetFullOrderString()); bool confirm = io.GetBool("Are you sure you would like to make these changes?"); if (confirm) { manager.SaveValidOrder(pendingChanges); result = "Edits saved."; } else { result = "Edits cancelled."; } } else { result = "No order found with given parameters. Returning to menu."; } io.WriteLine(result); io.WaitForUser("Press any key to continue..."); }
public void Execute() { OrderManager manager = OrderManagerFactory.Create(); IUserIO io = new ConsoleIO(); //This can be replaced with a factory if we ever use multiple IO types io.Clear(); io.WriteLine("Order Lookup By Date"); io.WriteLine(new string('*', 27)); DateTime target = io.GetDate("Please enter a date to look up."); io.WriteLine(manager.GetAllOrders(target)); io.WaitForUser("Press any key to continue..."); }
//Ask date an order number //if exizts, display order //prompt if want to remove //if no, return to main menu public void Execute() { Manager manager = ManagerFactory.Create(); ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Remove Order"); ConsoleIO.SeperatorBar(); DateTime orderDate = ConsoleIO.RetrieveOrderDateFromUser("Please Enter a Date (Format: MM/DD/YYYY): "); int orderNumber = ConsoleIO.RetrieveOrderNumberFromUser("Please Enter an Order Number: "); OrderResponse response = manager.RetrieveOrder(orderDate, orderNumber);//Takes in user entered info, checks if (response.Success) { ConsoleIO.DisplaySingleOrder(response.Order); } else { ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(response.Message); } //Remove Confirmation ConsoleIO.GeneralPrompt("Delete Order Confirmation"); ConsoleIO.BlankLine(); ConsoleIO.SeperatorBar(); bool removeOrderConfirmation = ConsoleIO.Confirmation("Would you like to remove this order? (Enter Y/N): "); if (removeOrderConfirmation == true) { manager.DeleteOrder(response.Order); ConsoleIO.GeneralPrompt($"Order {orderNumber} for {orderDate} has been removed."); ConsoleIO.BlankLine(); } else { ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Order Removal Canceled."); ConsoleIO.BlankLine(); } ConsoleIO.ReadKeyPlusPrompt("Press any key to continue..."); }
public void Execute() { Manager manager = ManagerFactory.Create(); ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Edit Order"); ConsoleIO.SeperatorBar(); DateTime orderDate = ConsoleIO.RetrieveOrderDateFromUser("Enter an order date (Format: MM/DD/YYYY): "); int orderNumber = ConsoleIO.RetrieveOrderNumberFromUser("Enter an order number: "); OrderResponse originalOrderResponse = manager.RetrieveOrder(orderDate, orderNumber);//ORIGiNAL/UNTOUCHED ORDER!!!!!!!!! //Check for existence of order if (originalOrderResponse.Success) { ConsoleIO.DisplaySingleOrder(originalOrderResponse.Order); } else { ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(originalOrderResponse.Message); } //Customer Name ConsoleIO.GeneralPrompt("Enter a new customer name or press enter to continue: "); string updatedCustomerName = Console.ReadLine(); if (string.IsNullOrEmpty(updatedCustomerName)) { updatedCustomerName = originalOrderResponse.Order.CustomerName;//If nothing entered, leave customer name the same } //State string updatedStateAB = ""; while (true) { ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Available States"); ConsoleIO.SeperatorBar(); ConsoleIO.BlankLine(); DisplayStatesResponse response = new DisplayStatesResponse(); response = manager.DisplayStateList(); if (response.Success) { ConsoleIO.DisplayListOfStates(response.States); } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(response.Message); } //Attempted to put in IO, not sure how. Problem: need to return string but one possible user submission is emptry string ConsoleIO.GeneralPrompt("Enter a new state abbreviation OR press enter to continue: "); updatedStateAB = Console.ReadLine().ToUpper(); if (string.IsNullOrEmpty(updatedStateAB)) { updatedStateAB = originalOrderResponse.Order.State; break; } else if (updatedStateAB.Length != 2) { ConsoleIO.GeneralPrompt("Error. State abbreviations must be 2 characters in length."); continue; } StateCheckResponse stateCheckResponse = new StateCheckResponse(); stateCheckResponse = manager.StateCheckAbbreviationEntry(updatedStateAB); if (stateCheckResponse.Success) { break; } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(stateCheckResponse.Message); ConsoleIO.GeneralPrompt("Press any key to try again..."); continue; } } //Product Type string updatedProductType = ""; while (true) { ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Available Products"); ConsoleIO.SeperatorBar(); ConsoleIO.BlankLine(); DisplayProductsResponse response = new DisplayProductsResponse(); response = manager.DisplayProductList(); if (response.Success) { ConsoleIO.DisplayListOfProducts(response.Products); } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(response.Message); } ConsoleIO.GeneralPrompt("Enter a new product type (Carpet, Laminate, Tile, Wood) OR press enter to continue: "); updatedProductType = Console.ReadLine(); if (string.IsNullOrEmpty(updatedProductType)) { updatedProductType = originalOrderResponse.Order.ProductType; } CheckProductResponse checkProductResponse = new CheckProductResponse(); checkProductResponse = manager.CheckProductTypeEntry(updatedProductType); if (checkProductResponse.Success) { break; } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(checkProductResponse.Message); continue; } } //Area decimal updatedAreaSize; while (true) { ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Enter a new area size OR press enter to continue: "); string updatedAreaSizeString = Console.ReadLine(); if (string.IsNullOrEmpty(updatedAreaSizeString)) { updatedAreaSizeString = originalOrderResponse.Order.Area.ToString(); updatedAreaSize = decimal.Parse(updatedAreaSizeString); break; } else if (decimal.TryParse(updatedAreaSizeString, out updatedAreaSize) && updatedAreaSize > 99) { ConsoleIO.GeneralPrompt("Area size has been changed."); ConsoleIO.BlankLine(); break; } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); continue; } } ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Updated Order"); ConsoleIO.SeperatorBar(); //Calculate remaining fields for order Order orderToUpdate = manager.CalculateDisplayUpdateOrder(orderDate, orderNumber, updatedCustomerName, updatedStateAB, updatedProductType, updatedAreaSize); //Display order with changes ConsoleIO.DisplaySingleOrder(orderToUpdate); //Confirm change while (true) { ConsoleIO.GeneralPrompt("Please review the edited order above."); bool updateConfirm = ConsoleIO.Confirmation("Are these edits correct? (Enter Y/N): "); if (updateConfirm == true) { //Call Calculate/Update order AND call repo to change manager.UpdateOrder(orderDate, orderNumber, updatedCustomerName, updatedStateAB, updatedProductType, updatedAreaSize); ConsoleIO.GeneralPrompt("Order edit successful."); break; } else { ConsoleIO.GeneralPrompt("Order edit cancelled."); break; } } ConsoleIO.ReadKeyPlusPrompt("Press any key to continue..."); }
//Questions/Concerns //================================= //Order Confirmation - Do I need a response object in case order creation in manager fails? //--If so, what to catch? public void Execute() { Manager manager = ManagerFactory.Create(); string productType = ""; string stateAbbreviation = ""; ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Add Order"); ConsoleIO.SeperatorBar(); DateTime orderDate = ConsoleIO.RetrieveOrderDateFromUser("Enter an order date (Format: MM/DD/YYYY): "); ConsoleIO.BlankLine(); string customerName = ConsoleIO.RetrieveCustomerNameFromUser("Enter a customer name: "); while (true) { ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Available States"); ConsoleIO.SeperatorBar(); ConsoleIO.BlankLine(); DisplayStatesResponse response = manager.DisplayStateList(); if (response.Success) { ConsoleIO.DisplayListOfStates(response.States); } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(response.Message); } stateAbbreviation = ConsoleIO.RetrieveStateAbbreviationFromUser("Enter a state abbreviation (Example: PA): "); StateCheckResponse stateCheckResponse = manager.StateCheckAbbreviationEntry(stateAbbreviation); if (stateCheckResponse.Success) { break; } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(stateCheckResponse.Message); ConsoleIO.ReadKeyPlusPrompt("Press any key to try again..."); } } //Product Type while (true) { ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Available Products"); ConsoleIO.SeperatorBar(); ConsoleIO.BlankLine(); DisplayProductsResponse response = manager.DisplayProductList(); if (response.Success) { ConsoleIO.DisplayListOfProducts(response.Products); } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(response.Message); } ConsoleIO.GeneralPrompt("Enter a Product Type (Carpet, Laminate, Tile, Wood)"); ConsoleIO.BlankLine(); productType = ConsoleIO.RetrieveProductTypeFromUser("(WARNING: Case Sensitive Entry): "); CheckProductResponse checkProductResponse = manager.CheckProductTypeEntry(productType); if (checkProductResponse.Success) { break; } else { ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("An error occurred."); ConsoleIO.GeneralPrompt(checkProductResponse.Message); continue; } } //Area ConsoleIO.BlankLine(); decimal area = ConsoleIO.RetrieveAreaSizeFromUser("Enter an area size (Minimum Amount = 100): "); //Display Order ConsoleIO.Clear(); ConsoleIO.GeneralPrompt("Here is your order:"); ConsoleIO.BlankLine(); Order orderToCreate = manager.CreateNewOrder(orderDate, customerName, stateAbbreviation, productType, area); ConsoleIO.DisplaySingleOrder(orderToCreate); //Confirm Add Order ConsoleIO.GeneralPrompt("Order Confirmation"); ConsoleIO.SeperatorBar(); bool addOrderConfirmation = ConsoleIO.Confirmation("Are you sure you would like to create the above order? (Enter Y/N): "); if (addOrderConfirmation == true) { manager.AddOrder(orderToCreate); ConsoleIO.BlankLine(); ConsoleIO.GeneralPrompt("Your order has been added to the system."); } else { ConsoleIO.GeneralPrompt("Order Creation Canceled."); ConsoleIO.BlankLine(); } ConsoleIO.ReadKeyPlusPrompt("Press any key to continue..."); }