Пример #1
0
        /// <summary>
        /// Displays a list of all orders, prompts the user to choose one to see detailed information about it
        /// </summary>
        public void Execute()
        {
            Console.Clear();
            _prompts.SetHeaderText("Display Order");

            string date = _prompts.GetDateFromCustomer();

            if (date == null)
            {
                Console.Clear();
                _wrappers.DrawHeader("Invalid date");
                Console.WriteLine("Returning to the main menu");
                _wrappers.DrawFooter();
                Thread.Sleep(1000);
                return;
            }

            int orderNumber = _prompts.GetOrderNumberFromUser(date);
            var orderManager = new OrderManager();

            if (orderNumber < 0 || orderNumber > orderManager.NumberOfOrdersInRepo(date))
            {
                Console.Clear();
                _wrappers.DrawHeader("Invalid Entry...");
                Console.WriteLine("Returning to the main menu");
                _wrappers.DrawFooter();
                Thread.Sleep(1000);
                return;
            }

            var customerOrder = RetreiveOrderByNumber(orderNumber, date);

            Console.Clear();

            _orderForm.DisplayFullOrder(customerOrder, $"Order #{customerOrder.OrderNumber}");
            Console.WriteLine();
            Console.Write("Press any key to go back to the main menu...");
            Console.ReadKey();
        }
Пример #2
0
        public void Execute()
        {
            Console.Clear();
            var orderManager = new OrderManager();
            _prompts.EditMode();
            _prompts.SetHeaderText(HeaderText);

            string date = _prompts.GetDateFromCustomer();

            if (date == null)
            {
                Console.Clear();
                _wrappers.DrawHeader("Invalid date");
                Console.WriteLine("Returning to the main menu");
                _wrappers.DrawFooter();
                Thread.Sleep(1000);
                return;
            }

            int orderNumber = _prompts.GetOrderNumberFromUser(date);

            if (orderNumber < 0 || orderNumber > orderManager.NumberOfOrdersInRepo(date))
            {
                Console.Clear();
                _wrappers.DrawHeader("Invalid Entry...");
                Console.WriteLine("Returning to the main menu");
                _wrappers.DrawFooter();
                Thread.Sleep(1000);
                return;
            }

            CustomerOrderResponse orderResponse = orderManager.DisplayCustomerOrder(orderNumber, date);

            if (!orderResponse.Success)
            {
                Console.Clear();
                _wrappers.DrawHeader(orderResponse.Message);
                _wrappers.DrawFooter();
                Thread.Sleep(1000);
                return;
            }

            Console.Clear();

            CustomerOrder orderEdit = new CustomerOrder();

            _prompts.SetHeaderText(HeaderText);
            //_orderForm.AddOrder(orderEdit, HeaderText);

            CustomerOrder order = orderResponse.Order;
            orderManager.OrderCalculations(order);
            //sets the new values to the old ones for reuse
            orderEdit.CustomerName = order.CustomerName;
            orderEdit.AreaString = order.AreaString;
            orderEdit.Area = order.Area;
            orderEdit.StateKey = order.StateKey;
            orderEdit.ProductKey = order.ProductKey;
            orderEdit.OrderNumber = order.OrderNumber;

            _orderForm.AddOrder(orderEdit, HeaderText);
            orderEdit = _prompts.GetNameFromCustomer(orderEdit);
            Console.Clear();
            _orderForm.AddOrder(orderEdit, HeaderText);
            orderEdit = _prompts.GetStateFromCustomer(orderEdit);
            Console.Clear();
            _orderForm.AddOrder(orderEdit, HeaderText);
            orderEdit = _prompts.GetProductFromCustomer(orderEdit);
            Console.Clear();
            _orderForm.AddOrder(orderEdit, HeaderText);
            orderEdit = _prompts.GetAreaFromCustomer(orderEdit);

            Console.Clear();
            orderEdit = orderManager.OrderCalculations(orderEdit);
            _orderForm.DisplayFullOrder(orderEdit, HeaderText);

            while(true)
            {
                Console.WriteLine("Save edited order (Y/N)");
                switch (Console.ReadKey(false).Key)
                {
                    case ConsoleKey.Y:

                        orderManager.EditOrder(orderEdit, orderNumber, date);
                        Console.Clear();
                        _wrappers.DrawHeader("Changes saved");
                        _wrappers.DrawFooter();
                        Thread.Sleep(1000);
                        return;
                    case ConsoleKey.N:
                        Console.Clear();
                        _wrappers.DrawHeader("Changes not saved");
                        _wrappers.DrawFooter();
                        Thread.Sleep(1000);
                        return;
                    default:
                        Console.Clear();
                        _orderForm.AddOrder(orderEdit, HeaderText);
                        Console.WriteLine("Press either Y or N");
                        continue;
                }
            }
        }
Пример #3
0
 public void RemoveOrderFromRepoTest()
 {
     var orderManager = new OrderManager();
     orderManager.RemoveOrder(3, _date);
        Assert.AreEqual(2,orderManager.NumberOfOrdersInRepo(_date));
 }
Пример #4
0
 public void NumberOfOrdersInRepoFail()
 {
     var orderManager = new OrderManager();
     int numberOforders = orderManager.NumberOfOrdersInRepo(_date);
     Assert.AreNotEqual(3, numberOforders);
 }
Пример #5
0
 public void AddOrderToRepoTest()
 {
     var orderManager = new OrderManager();
     orderManager.AddOrderToRepo(_order,_date);
     Assert.AreEqual(4,orderManager.NumberOfOrdersInRepo(_date));
 }
Пример #6
0
        public void Execute()
        {
            Console.Clear();

            var orderManager = new OrderManager();

            _displayFullList.Products();
            _prompts.SetHeaderText("Remove Order");

            string date = _prompts.GetDateFromCustomer();

            if (date == null)
            {
                Console.Clear();
                _wrappers.DrawHeader("Invalid date");
                Console.WriteLine("Returning to the main menu");
                _wrappers.DrawFooter();
                Thread.Sleep(1000);
                return;
            }

            int orderNumber = _prompts.GetOrderNumberFromUser(date);

            if (orderNumber < 0 || orderNumber > orderManager.NumberOfOrdersInRepo(date))
            {
                Console.Clear();

                _wrappers.DrawHeader("Invalid Entry...");
                Console.WriteLine("Returning to the main menu");
                _wrappers.DrawFooter();
                Thread.Sleep(1000);

                return;
            }

            CustomerOrderResponse orderResponse = orderManager.DisplayCustomerOrder(orderNumber, date);

            if (!orderResponse.Success)
            {
                Console.Clear();
                _wrappers.DrawHeader(orderResponse.Message);
                _wrappers.DrawFooter();
                Thread.Sleep(1000);
                return;
            }
            Console.Clear();
            _orderForm.DisplayFullOrder(orderResponse.Order, $"Remove Order?");
            Console.WriteLine();
            while (true)
            {
                Console.Write("Are you sure you want to remove this order? (Y/N) ");
                switch (Console.ReadKey(false).Key)
                {
                    case ConsoleKey.Y:
                        Console.Clear();
                        orderManager.RemoveOrder(orderNumber, date);
                        _wrappers.DrawHeader("Order has been removed");
                        _wrappers.DrawFooter();
                        Thread.Sleep(1000);
                        return;
                    case ConsoleKey.N:
                        Console.Clear();
                        _wrappers.DrawHeader("Order has not been removed");
                        _wrappers.DrawFooter();
                        Thread.Sleep(1000);
                        return;
                    default:
                        Console.Clear();
                        _orderForm.DisplayFullOrder(orderResponse.Order, $"Remove Order #{orderNumber}?");
                        Console.WriteLine();
                        Console.WriteLine("Please press the Y or N key...");
                        continue;
                }
            }
        }