public void RunCLI() { ParkDAL parkDAL = new ParkDAL(connectionString); List <Park> parks = parkDAL.GetParks(); Console.Clear(); Console.WriteLine("Select a Park for Further Details"); int i = 1; //menu index foreach (Park park in parks) { Console.WriteLine(i.ToString() + ")".PadRight(4) + park.Name); i++; } Console.WriteLine("Q)".PadRight(4) + " Quit"); string input = CLIHelper.GetString("Please enter a selection: "); if (input.ToLower().Equals("q")) { Environment.Exit(1); } else if (int.Parse(input) > 0 && int.Parse(input) < i) { ViewParkInfo(parks[int.Parse(input) - 1].ParkID); } else { Console.WriteLine("Make a valid selection"); } return; }
/// <summary> /// Handles the Main Menu /// </summary> private void MainMenu() { while (true) { // Print the main menu and take user input int input = PrintMainMenu(); // Retrieve the list of parks List <Park> parks = parkDAL.GetParks(); // If the user chose to quit, close the program if (input == parks.Count + 1) { Console.Clear(); ResizeAndExitWindow(); return; } // Otherwise, enter the Parks menu usering the user's designated park else { ParkMenu(parks[input - 1]); } } }
public bool IsValidParkId(int userSelectedParkId) { ParkDAL parkDAL = new ParkDAL(connectionString); List <Park> parks = parkDAL.GetParks(); int invalidCount = 0; foreach (Park park in parks) { if (park.Id != userSelectedParkId) { invalidCount++; } } if (invalidCount == parks.Count) { return(false); } return(true); }
public void Run() { bool isDone = false; ParkDAL parkDAL = new ParkDAL(connectionString); List <Park> parks = parkDAL.GetParks(); do { ParkInfoMenu(parks); try { int userSelection = Int32.Parse(Console.ReadLine()); if (userSelection == 0) { isDone = true; return; } else if (!IsValidParkId(userSelection)) { Console.WriteLine(""); Console.WriteLine("Sorry, that is not a valid park ID."); } else { InformationForSelectedPark(userSelection); } } catch (Exception ex) { Console.WriteLine(); Console.WriteLine("Not a valid input- please try again"); } }while (!isDone); }
public bool ParkDisplay() { Console.Clear(); ParkDAL parkDAL = new ParkDAL(connectionString); List <Park> parks = parkDAL.GetParks(); Console.WriteLine(" __ __ ___ ______ __ ___ __ __ ___ __ ____ ___ ____ __ __ __"); Console.WriteLine(@" ||\ || // \\ | || | || // \\ ||\ || // \\ || || \\ // \\ || \\ || // (( \"); Console.WriteLine(@" ||\\|| ||=|| || || (( )) ||\\|| ||=|| || ||_// ||=|| ||_// ||<< \\ "); Console.WriteLine(@" || \|| || || || || \\_// || \|| || || ||__| || || || || \\ || \\ \_))"); Console.WriteLine(); Console.WriteLine(@" ........::::::::::::.. .......|...............::::::::........"); Console.WriteLine(@" .:::::; ; ; ; ; ; ; ; ; ; ;:::::.... . \ | ../....::::; ; ; ;:::::.."); Console.WriteLine(@" . ........... / \\_ \ | / ...... . ........./\"); Console.WriteLine(@"...:::../\\_ ...... ..._/' \\\_ \###/ /\_ .../ \_....... _//"); Console.WriteLine(@".::::./ \\\ _ .../\ /' \\\\#######// \/\ // \_ ....////"); Console.WriteLine(@" _/ \\\\ _/ \\\ / x \\\\###//// \//// \__ _/////"); Console.WriteLine(@" ./ x \\\/ \/ x X \////// \/////"); Console.WriteLine(@" / XxX \\/ XxX X //// x"); Console.WriteLine(@"-----XxX-------------|-------XxX-----------*--------|---*-----|------------X--"); Console.WriteLine(@" X _X * X ** ** x ** * X"); Console.WriteLine(@" _X _X x * x X_"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(" *".PadRight(33, '*')); Console.WriteLine(" Select a Park for Further Details"); Console.WriteLine(" *".PadRight(33, '*')); foreach (Park p in parks) { Console.WriteLine($" |{p.AlphaID}| {p.Name}"); } Console.WriteLine(" |Q| Quit"); string input = Console.ReadLine(); if (input.ToLower() == "q") { return(false); } else { foreach (Park p in parks) { if (input == p.AlphaID.ToString()) { bool running = true; while (running) { running = ParkInfoScreen(p); } return(true); } } Console.WriteLine(" Please enter a valid park. Press any key to continue."); Console.ReadKey(); } return(true); }