private void ParkInfoScreenCLI(Park park) { Console.Clear(); string snName = "Park Information Menu"; Console.SetCursorPosition((Console.WindowWidth - snName.Length) / 2, Console.CursorTop); Console.WriteLine(snName); string snNameDash = "---------------------"; Console.SetCursorPosition((Console.WindowWidth - snNameDash.Length) / 2, Console.CursorTop); Console.WriteLine(snNameDash); Console.WriteLine(); Console.WriteLine("{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}", "NAME", "LOCATION", "ESTABLISHED", "AREA", "ANNUAL VISITORS"); Console.WriteLine("{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}", park.Name, park.Location, park.EstablishDate.ToShortDateString(), park.Area.ToString("N0"), park.Visitors.ToString("N0")); Console.WriteLine(); Console.WriteLine("1) View Campgrounds"); Console.WriteLine("2) Park Wide Campsite Search"); Console.WriteLine("3) See All Upcoming Reservations for next 30 Days"); Console.WriteLine(); string input = CLIHelper.GetIntInRangeOrQ("Select a Option for Further Details or Press (R) to Return to Previous Menu", 1, 3, "R", true); if (input == "1") { Console.Clear(); GetAllCampgroundsForParkCLI(park); } else if (input == "2") { Console.Clear(); ParkWideSearchCLI(park); } else if (input == "3") { Console.Clear(); SeeUpcomingReservationsForParkCLI(park); } Console.WriteLine($"Press any key to return to Park Selection Menu"); }
public void RunCLI() { bool programOver = false; while (!programOver) { PrintHeader(); PrintMenu(); string input = CLIHelper.GetIntInRangeOrQ("Select a Menu Item for Further Details or Press (Q) to Quit", 1, 1, "Q", true); if (input == "1") { GetParksCLI(); } else if (input == "Q" || input == "q") { programOver = true; } } }
private void GetParksCLI() { bool getParksCLIOver = false; while (!getParksCLIOver) { Console.Clear(); ParkDAL parkDal = new ParkDAL(DatabaseConnection); List <Park> parks = parkDal.GetParks(); string snName = "Park Menu"; Console.SetCursorPosition((Console.WindowWidth - snName.Length) / 2, Console.CursorTop); Console.WriteLine(snName); string snNameDash = "---------"; Console.SetCursorPosition((Console.WindowWidth - snNameDash.Length) / 2, Console.CursorTop); Console.WriteLine(snNameDash); Console.WriteLine(); for (int i = 0; i < parks.Count; i++) { Console.WriteLine($"{i + 1}) {parks[i].Name}"); } Console.WriteLine(); string input = CLIHelper.GetIntInRangeOrQ("Select a Park for Further Details or Press (Q) to Quit", 1, parks.Count, "Q", true); if (input == "Q" || input == "q") { Console.Clear(); getParksCLIOver = true; } else { ParkInfoScreenCLI(parks[Convert.ToInt16(input.ToString()) - 1]); } } }
public string DisplaySitesAndGetUserInput(List <Site> sites, Campground campground, DateTime userArrivalDate, DateTime userDepartureDate) { Console.Clear(); string snName = "Search for Campground Reservation Menu"; Console.SetCursorPosition((Console.WindowWidth - snName.Length) / 2, Console.CursorTop); Console.WriteLine(snName); string snNameDash = "--------------------------------------"; Console.SetCursorPosition((Console.WindowWidth - snNameDash.Length) / 2, Console.CursorTop); Console.WriteLine(snNameDash); Console.WriteLine(); Console.WriteLine("{0,-25}{1,-15}{2,-15}{3,-15}", "CAMPGROUND", "OPEN", "CLOSE", "DAILY FEE"); Console.WriteLine("{0,-25}{1,-15}{2,-15}{3,-15}", campground.Name, campground.GetMonthString(true), campground.GetMonthString(false), campground.DailyFee); Console.WriteLine(); Console.WriteLine($"Reservation Start Date: {userArrivalDate.ToShortDateString()}"); Console.WriteLine($"Reservation End Date: {userDepartureDate.ToShortDateString()}"); Console.WriteLine($"Reservation Total Fee: " + campground.CostOfStayForSite(userArrivalDate, userDepartureDate).ToString("c")); Console.WriteLine(); string input = "zzz"; if (sites.Count() > 5) { for (int i = 1; i <= 5; i++) { if (i == 1) { Console.WriteLine("{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}", "SITE NO.", "MAX OCCUP.", "ACCESSIBLE", "RV LENGTH", "UTILITY"); } Console.WriteLine("{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}", sites[i - 1].SiteId, sites[i - 1].MaxOccupancy, sites[i - 1].Accessible, sites[i - 1].MaxRVLength, sites[i - 1].Utilities); } Console.WriteLine(); input = CLIHelper.GetIntInRangeOrQ("Select a Site Number (+ enter) to Make a Reserveration or Press (R + enter) to Return to Previous Menu", sites[0].SiteId, sites[sites.Count() - 1].SiteId, "R", false); } else if (sites.Count() < 6 && sites.Count() > 0) { for (int i = 1; i <= sites.Count(); i++) { if (i == 1) { Console.WriteLine("{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}", "SITE NO.", "MAX OCCUP.", "ACCESSIBLE", "RV LENGTH", "UTILITY"); } Console.WriteLine("{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}", sites[i - 1].SiteId, sites[i - 1].MaxOccupancy, sites[i - 1].Accessible, sites[i - 1].MaxRVLength, sites[i - 1].Utilities); } Console.WriteLine(); input = CLIHelper.GetIntInRangeOrQ("Select a Site Number (+ enter) to Make a Reserveration or Press (R + enter) to Return to Previous Menu", sites[0].SiteId, sites[sites.Count() - 1].SiteId, "R", false); } else if (sites.Count() == 0) { Console.WriteLine("Sorry There are no sites available at your selected campground on your selected dates :("); Console.WriteLine("Press Any Key to return to the Park Menu"); Console.ReadKey(); } return(input); }
private void GetAllCampgroundsForParkCLI(Park park) { CampgroundDAL campgroundDAL = new CampgroundDAL(DatabaseConnection); ReservationDAL reservationDAL = new ReservationDAL(DatabaseConnection); List <Campground> campgrounds = campgroundDAL.GetAllCampgroundsForPark(park); bool doneWithMenu = false; while (!doneWithMenu) { Console.Clear(); //Displaying menu items string snName = "Park Campground Menu"; Console.SetCursorPosition((Console.WindowWidth - snName.Length) / 2, Console.CursorTop); Console.WriteLine(snName); string snNameDash = "--------------------"; Console.SetCursorPosition((Console.WindowWidth - snNameDash.Length) / 2, Console.CursorTop); Console.WriteLine(snNameDash); Console.WriteLine(); for (int i = 1; i <= campgrounds.Count; i++) { if (i == 1) { Console.WriteLine("{0,-5}{1,-35}{2,-10}{3,-10}{4,-10}", " ", "NAME", "OPEN", "CLOSE", "DAILY FEE"); } Console.WriteLine("{0,-5}{1,-35}{2,-10}{3,-10}{4,-10}", i + ")", campgrounds[i - 1].Name, campgrounds[i - 1].GetMonthString(true), campgrounds[i - 1].GetMonthString(false), campgrounds[i - 1].DailyFee.ToString("c")); } Console.WriteLine($""); //Selecting a campground string userCampground = CLIHelper.GetIntInRangeOrQ("Which campground would you like to make a reservation at? [or press (Q) to quit]", 1, campgrounds.Count(), "q", true); Console.WriteLine(); if (userCampground.ToLower() == "q") { doneWithMenu = true; } else { //Get Date and Time Dictionary <bool, DateTime> startDateTrueEndDateFalse = GetStartAndEndDates(); DateTime userArrivalDate = startDateTrueEndDateFalse[true]; DateTime userDepartureDate = startDateTrueEndDateFalse[false]; bool datesGood = false; while (!datesGood) { bool campgroundOpen = true; try { reservationDAL.IsCampgroundOpen(campgrounds[int.Parse(userCampground) - 1], userArrivalDate, userDepartureDate); } catch (Exception e) { Console.WriteLine(e.Message); campgroundOpen = false; } if (campgroundOpen) { datesGood = true; } } bool wantAdvancedSearch = CLIHelper.GetBoolCustom("Would you like to check additional site requirements with our advanced search?", "yes", "no"); if (wantAdvancedSearch) { AdvancedSearchGetSitesCLI(campgrounds[int.Parse(userCampground) - 1], userArrivalDate, userDepartureDate); } else if (!wantAdvancedSearch) { GetAllSitesForCampgroundCLI(campgrounds[int.Parse(userCampground) - 1], userArrivalDate, userDepartureDate); } doneWithMenu = true; } } }