Exemplo n.º 1
0
        //private List<Order> myVar = Orders;
        public void Execute()
        {
            CommonIO.ShowHeader("Lookup an order");

            List <Order> _allOrders = new List <Order>();
            DateTime     OrderDate  = ConsoleIO.AskForOrderDate();

            OrdrLkpResponses AllOrders = new OrdrLkpResponses();

            AllOrders = _manager.LoadOrders(OrderDate);

            _allOrders = AllOrders.Orders;

            Console.Clear();

            if (AllOrders.Success)
            {
                foreach (Order OneOrder in _allOrders)
                {
                    ConsoleIO.DisplayOrderDetails(OneOrder);
                }
                CommonIO.Continue();
            }
            else
            {
                CommonIO.MessageToUserInBlue(AllOrders.Message);
            }
        }
Exemplo n.º 2
0
        public void Execute()
        // The construct doesn't get executed when a method is static.
        // But, without having this static makes it difficult to count orders
        // AND diffiuclt to get the next order number.
        {
            Order orderFromUsr = new Order();

            CommonIO.ShowHeader("Add an order");

            orderFromUsr = ConsoleIO.GetNewOrder();

            OrdrLkpResponses AllOrders = new OrdrLkpResponses();

            AllOrders = _manager.LoadOrders(orderFromUsr.OrderDate);

            if (AllOrders.Success)
            {
                _orders = AllOrders.Orders;
            }
            else
            {
                Console.WriteLine("An error occurred: ");
                Console.WriteLine(AllOrders.Message);
            }

            orderFromUsr = CalcRestofOrder(orderFromUsr);
            //DateTime OrderDate = orderFromUsr.OrderDate;
            CommonIO.MessageToUserInBlue("Order entry is complete.");
            CommonIO.Continue();

            ConsoleIO.DisplayOrderDetails(orderFromUsr);

            String userConfirm = ConsoleIO.RequireYorN("Would you like to save this information? (y=Yes, n=No.)");

            if (userConfirm.ToUpper() == "Y")
            {
                //List<Order> AllOrders = _manager.LoadOrders(DateTime.Now);

                _manager.SaveOrder(orderFromUsr);
                //manager.SaveOrders(AllOrders);
                CommonIO.MessageToUserInBlue($"New order ID {orderFromUsr.OrderNumber} has been saved.");
                CommonIO.Continue();
            }
            else
            {
                CommonIO.MessageToUserInBlue($"New order ID {orderFromUsr.OrderNumber} was NOT saved.");
                CommonIO.Continue();
            }
        }
Exemplo n.º 3
0
        public void Execute()
        {
            //OrderManager manager = OrderManagerFactory.Create();

            CommonIO.ShowHeader("Edit an order");
            OrderLookupResponse response = ConsoleIO.AskForExistingOrder();

            if (response.Success)
            {
                EditOrderIO.ShowEditInstructions();
                GetEdits(response.Order);
                SaveOrderToList(response.Order);
            }
            else
            {
                Console.WriteLine("An error occurred: ");
                CommonIO.errMsg(response.Message);
            }
        }
Exemplo n.º 4
0
        public void Execute()
        {
            CommonIO.ShowHeader("Delete Order");
            DateTime OrderDateToDelete = ConsoleIO.AskForOrderDate();

            OrdrLkpResponses AllOrders = new OrdrLkpResponses();

            AllOrders = _manager.LoadOrders(OrderDateToDelete);

            if (AllOrders.Success)
            {
                _orders = AllOrders.Orders;
                int orderNumtoDelete = CommonIO.GetIntFromUser(1, 999, 0, "What order number would you like to delete?");
                DeleteOrder(OrderDateToDelete, orderNumtoDelete);
            }
            else
            {
                CommonIO.MessageToUserInBlue(AllOrders.Message);
            }
        }