コード例 #1
0
        public void Execute()
        {
            DataManager       manager   = DataManagerFactory.Create();
            DateTime          OrderDate = ConsoleIO.RequestAndValidateDate("edit");
            FileLookupRequest request   = manager.FileLookup(OrderDate);

            if (!request.success)
            {
                Console.WriteLine("Error: No orders found for that date.");
                Console.WriteLine();
                return;
            }

            string path = request.path;

            int OrderNumber = ConsoleIO.RequestAndValidateOrderNumber();

            List <Order> orders = request.orders;
            Order        o;

            foreach (Order OrderToCheck in orders)
            {
                if (OrderToCheck.OrderNumber == OrderNumber)
                {
                    o = OrderToCheck;
                    ConsoleIO.PrintOrder(o, OrderDate);
                    EditOrderInfo(o);
                    ConsoleIO.PrintOrder(o, OrderDate);
                    if (ConsoleIO.ConfirmEditOrRemoveOrder("save"))
                    {
                        manager.FileSave(o, OrderDate.ToString("MMddyyyy"), path);
                        Console.WriteLine("Order saved.");
                        return;
                    }
                    else
                    {
                        Console.WriteLine("Order not saved.");
                        return;
                    }
                }
                else
                {
                    continue;
                }
            }
            Console.WriteLine("There is no order with that order number.");
        }