Exemple #1
0
        private void registrationNumberDisplayMenu()
        {
            try
            {
                bool isFilter           = false;
                bool isFilterByInRepair = false;
                bool isFilterByFixed    = false;
                bool isFilterByPaid     = false;

                string userChoice = string.Empty;
                int    registrationNumbersListCount = 0;

                isFilter = getYesOrNoFromUser("Would you like to filter out vehicles?  Enter Y/N");

                if (isFilter == true)
                {
                    isFilterByInRepair = getYesOrNoFromUser("Would you like to filter by In Repair status? (Y/N)");
                    isFilterByFixed    = getYesOrNoFromUser("Would you like to filter by Fixed status? (Y/N)");
                    isFilterByPaid     = getYesOrNoFromUser("Would you like to filter by Paid status? (Y/N)");
                }

                List <string> RegNumberList = m_Garage.GetRegistrationNumbersList(isFilterByInRepair, isFilterByFixed, isFilterByPaid);

                if (RegNumberList.Count != 0)
                {
                    Console.WriteLine("Displaying registration numbers: ");

                    foreach (string registrationNum in RegNumberList)
                    {
                        registrationNumbersListCount++;
                        Console.WriteLine("Vehicle No.{0}: {1}", registrationNumbersListCount, registrationNum);
                    }
                }
                else
                {
                    Console.WriteLine("Error: Couldn't find any vehicle. Please try again or enter a new vehicle.");
                }
            }
            catch (FormatException)
            {
                Console.WriteLine("Error: Input format does not match the format type required.{0}", Environment.NewLine);
            }
            catch (Exception i_Ex)
            {
                if (i_Ex.Message == "Invalid data input")
                {
                    Console.WriteLine("Error: {0}.{1}", i_Ex.Message, Environment.NewLine);
                }
                else
                {
                    Console.WriteLine("Error: Unknown.{0}", Environment.NewLine);
                }
            }
        }