public void Execute() { CustomerOrder order = new CustomerOrder(); OrderManager orderManager = new OrderManager(); Prompts prompts = new Prompts(); Wrappers wrappers = new Wrappers(); _headerText = "Add Order"; string date = $"{DateTime.Today.Month.ToString()}{DateTime.Today.Day.ToString()}{DateTime.Today.Year.ToString()}"; Console.Clear(); prompts.SetHeaderText(_headerText); order = prompts.GetNameFromCustomer(order); order = prompts.GetStateFromCustomer(order); order = prompts.GetProductFromCustomer(order); order = prompts.GetAreaFromCustomer(order); Console.Clear(); _orderForm.AddOrder(order, _headerText); order = orderManager.SetOrderNumber(order, date); order = orderManager.OrderCalculations(order); Console.Clear(); _orderForm.DisplayFullOrder(order, _headerText); Console.WriteLine(); while (true) { Console.WriteLine("Would you like to save this order? (Y/N)"); switch (Console.ReadKey(false).Key) { case ConsoleKey.Y: orderManager.AddOrderToRepo(order, date); Console.Clear(); wrappers.DrawHeader("Order Saved"); wrappers.DrawFooter(); Thread.Sleep(1000); return; case ConsoleKey.N: Console.Clear(); wrappers.DrawHeader("Order not Saved"); wrappers.DrawFooter(); Thread.Sleep(1000); return; default: Console.Clear(); _orderForm.DisplayFullOrder(order, _headerText); Console.WriteLine(); Console.WriteLine("Press Y to save or N to abandon the order..."); break; } } }
/// <summary> /// Gets the Order date from the customer /// </summary> /// <returns>Validated date or null if invalid</returns> public string GetDateFromCustomer() { Console.Clear(); var wrappers = new Wrappers(); wrappers.DrawHeader("Order Dates"); _displayFullList.Files(); wrappers.DrawFooter(); var directoryManager = new DirectoryManager(); Console.WriteLine(); Console.Write("Please pick a date from the list: "); string input = Console.ReadLine(); if (!directoryManager.CheckDate(input)) { return null; } return directoryManager.TranslateDate(input); }