Ejemplo n.º 1
0
 /// <summary>
 /// Gets the detailed order information
 /// </summary>
 /// <param name="orderNumber">Number of order you want to display</param>
 /// <param name="date">Date where the repo lives</param>
 /// <returns>an order</returns>
 private static CustomerOrder RetreiveOrderByNumber(int orderNumber, string date)
 {
     var ops = new OrderManager();
     var response = ops.DisplayCustomerOrder(orderNumber, date);
     if (response.Success)
     {
         return response.Order;
     }
     Console.WriteLine("Error Occurred!!!!");
     Console.WriteLine(response.Message);
     Console.WriteLine("Go away now...");
     Console.ReadLine();
     return null;
 }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 3
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;
                }
            }
        }