예제 #1
0
        public Order GetEdits(Order OrderToEdit)
        {
            //Order EditedOrder = new Order();

            // Edit Customer Name
            Console.Write($"Customer Name ({OrderToEdit.CustomerName}), ");
            CommonIO.MessageToUserInBlue("press Enter for no change.");
            String newCustomerName = ConsoleIO.AskForNewCustomerName();

            if (newCustomerName == "")
            {
                Console.WriteLine("Name Unchanged\n");
            }
            else
            {
                OrderToEdit.CustomerName = newCustomerName;
            }

            // Edit State
            Console.WriteLine($"Order State ({OrderToEdit.State}):");
            CommonIO.MessageToUserInBlue("  0. No change");
            String newState = ConsoleIO.AskForNewStateAbbr();

            if (newState != null)
            {
                Console.WriteLine("State Unchanged");
            }
            else
            {
                OrderToEdit.State = newState;
            }

            // Edit Product
            Console.WriteLine($"Product ({OrderToEdit.ProductType}):");
            CommonIO.MessageToUserInBlue("  0. No change");
            Product EditedProduct = ConsoleIO.AskForNewProduct();

            if (newState == null)
            {
                Console.WriteLine("Product Unchanged");
            }
            else
            {
                OrderToEdit.State = newState;
            }

            // Edit Area
            Console.WriteLine($"Area ({OrderToEdit.Area}), ");
            CommonIO.MessageToUserInBlue("Enter 0 for no change.");

            //Decimal editedArea = ConsoleIO.AskForArea();

            decimal editedArea = 0;

            int  min = 100, max = 100000;
            bool intCk = false;

            do
            {
                intCk = decimal.TryParse(Console.ReadLine(), out editedArea);

                if (!intCk)
                {
                    editedArea = 1;
                }
                if (editedArea == 0)
                {
                    CommonIO.MessageToUserInBlue("Area unchanged.");
                    break;
                }
                else if (editedArea < min)
                {
                    CommonIO.MessageToUserInBlue($"Please enter a number between {min} and {max}");
                    //CommonIO.Continue();
                }
            } while (editedArea < min || editedArea > max);

            if (editedArea != 0)
            {
                OrderToEdit.Area = editedArea;
            }

            CommonIO.MessageToUserInBlue("Editing order is complete. Next, you'll view the edited order and decide if you want to save it.");
            CommonIO.Continue();
            Console.Clear();
            ConsoleIO.DisplayOrderDetails(OrderToEdit);

            //•	CustomerName, State, ProductType, Area
            return(OrderToEdit);
        }