/// <summary> /// Preforms a search for campsites available to be reserved /// </summary> /// <param name="currentPark">The park to find a reservation in.</param> /// <param name="fromWholePark">Option to search through all campgrounds in the specified Park.</param> private void SearchForReservation(Park currentPark, bool fromWholePark) { Console.Clear(); //Initialize working variables List <Campground> campgrounds = campDAL.GetCampgrounds(currentPark); List <Site> sites = new List <Site>(); DateTime startDate = DateTime.MinValue; DateTime endDate = DateTime.MinValue; int input = -1; bool continueSearching = true; do { //If the reservation is for a specific campground if (!fromWholePark) { campgrounds = campDAL.GetCampgrounds(currentPark); Console.WriteLine($"Campgrounds in {currentPark.Name}"); PrintCampgroundList(currentPark); //Print list of campgrounds in park to screen //Ask for user choice Console.Write("Which Campground (enter 0 to cancel)? "); input = CLIHelper.GetAnInteger(0, campgrounds.Count); //If User chose a campground, make the list only contain their choice if (input != 0) { campgrounds = new List <Campground>() { campgrounds[input - 1] }; } } //initialize advanced search criteria if (input != 0) { int occupants = 1; bool isAccessible = false; int RVLength = 0; bool hasUtilities = false; //Get reservation dates in correct format Console.Write(">Enter a Start Date for Reservation: "); startDate = CLIHelper.GetDateTime(DateTime.Now.Date); Console.Write(">Enter a Departure Date for Reservation: "); endDate = CLIHelper.GetDateTime(startDate); //Ask user for optional advanced search Console.Write("Would You Like to Preform an Advanced Search? (Y/N): "); bool isAdvancedSearch = CLIHelper.GetBoolean(); //Get user specified advanced search criteria if (isAdvancedSearch) { Console.WriteLine(); Console.Write("How many occupants: "); occupants = CLIHelper.GetAnInteger(1, 55); Console.Write("Do you need Wheelchair Accessiblity? (Y/N): "); isAccessible = CLIHelper.GetBoolean(); Console.Write("How long is your RV? (Enter 0 if not applicable): "); RVLength = CLIHelper.GetAnInteger(0, 35); Console.Write("Utilities Required? (Y/N): "); hasUtilities = CLIHelper.GetBoolean(); } //Print a list of sites that match the search criteria sites = PrintSiteList(startDate, endDate, campgrounds, occupants, isAccessible, RVLength, hasUtilities); //if there are no sites ask to try again or quit if (sites.Count == 0) { Console.Clear(); Console.WriteLine("No Available Sites per Your Specifications."); Console.Write("Would You Like to Try Again? (Y/N): "); continueSearching = CLIHelper.GetBoolean(); Console.WriteLine(); } } //Loop while the search return empty and user has not chosen to continue/quit } while (sites.Count == 0 && input != 0 && continueSearching); //Book a reservation if sites were found if (sites.Count != 0) { BookAReservation(sites, startDate, endDate); } }