public static void EditOrderInfo(Order o)
        {
            Console.WriteLine();
            Console.WriteLine("Please enter new values for only those order attributes you want to edit.\nIf you want to leave an attribute as it is, just hit enter.");
            Console.WriteLine();
            Console.WriteLine("Customer name?");
            string name = Console.ReadLine();

            if (!string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name))
            {
                o.CustomerName = name;
            }

            while (true)
            {
                Console.WriteLine("State?");
                string state = Console.ReadLine();
                if (!string.IsNullOrEmpty(state) && !string.IsNullOrWhiteSpace(state))
                {
                    bool StateOK = Controllers.FindStateInTaxFile(o, state);
                    if (!StateOK)
                    {
                        continue;
                    }
                }
                break;
            }

            ProductTypeRequest request = Controllers.ShowProductTypes();

            if (!request.success)
            {
                return;
            }

            while (true)
            {
                Console.WriteLine("Product?");
                string UserProduct = Console.ReadLine();

                if (!string.IsNullOrEmpty(UserProduct) && !string.IsNullOrWhiteSpace(UserProduct))
                {
                    bool found = Controllers.ProcessProductChoice(o, request.rows, UserProduct);
                    if (!found)
                    {
                        continue;
                    }
                }
                break;
            }

            while (true)
            {
                Console.WriteLine("Area?");
                string UserArea = Console.ReadLine();
                if (!string.IsNullOrEmpty(UserArea) && !string.IsNullOrWhiteSpace(UserArea))
                {
                    bool NewAreaOK = Controllers.CheckUserArea(o, UserArea);
                    if (!NewAreaOK)
                    {
                        continue;
                    }
                }
                break;
            }
            Controllers.CalculateRestOfOrder(o);
        }
示例#2
0
        public void Execute()
        {
            DataManager manager = DataManagerFactory.Create();

            while (true)
            {
                DateTime OrderDate = ConsoleIO.RequestAndValidateDate("add");

                if (OrderDate < DateTime.Now)
                {
                    Console.WriteLine("Date must be in the future.");
                    continue;
                }

                Order o = new Order();

                Console.WriteLine("Customer Name?");
                o.CustomerName = Console.ReadLine();

                while (true)
                {
                    Console.WriteLine("State?");
                    string UserState = Console.ReadLine();
                    bool   StateOK   = Controllers.FindStateInTaxFile(o, UserState);
                    if (!StateOK)
                    {
                        continue;
                    }
                    break;
                }

                while (true)
                {
                    ProductTypeRequest productRequest = Controllers.ShowProductTypes();
                    if (!productRequest.success)
                    {
                        continue;
                    }
                    while (true)
                    {
                        if (!GetProductType(o, productRequest.rows))
                        {
                            continue;
                        }
                        break;
                    }
                    break;
                }

                while (true)
                {
                    Console.WriteLine("Area?");
                    string UserArea = Console.ReadLine();
                    bool   AreaOK   = Controllers.CheckUserArea(o, UserArea);
                    if (!AreaOK)
                    {
                        continue;
                    }
                    break;
                }

                Controllers.CalculateRestOfOrder(o);

                ConsoleIO.PrintOrder(o, OrderDate);

                Console.WriteLine("Do you want to add this order? Y/N");
                string AddOrNot = Console.ReadLine().ToUpper();
                if (AddOrNot[0] != 'Y')
                {
                    break;
                }

                FileLookupRequest request = manager.FileLookup(OrderDate);

                if (!request.success)
                {
                    o.OrderNumber = 1;
                    manager.FileSave(o, OrderDate.ToString("MMddyyyy"), request.path);
                    Console.WriteLine($"Order file created for {OrderDate:MM/dd/yyyy}.");
                    break;
                }
                else
                {
                    List <Order> Orders = request.orders;
                    o.OrderNumber = Orders[(Orders.Count() - 1)].OrderNumber + 1;
                    manager.FileSave(o, OrderDate.ToString(), request.path);
                    Console.WriteLine($"Order added to file for {OrderDate:MM/dd/yyyy}.");
                    break;
                }
            }
        }