예제 #1
0
        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;
                }
            }
        }
예제 #2
0
 public void AddOrderToRepoTest()
 {
     var orderManager = new OrderManager();
     orderManager.AddOrderToRepo(_order,_date);
     Assert.AreEqual(4,orderManager.NumberOfOrdersInRepo(_date));
 }