private void GetCampgroundAvailability(Dictionary <int, Campground> campgrounds) { CampgroundSqlDAL campgroundDAL = new CampgroundSqlDAL(); int campground = CLIHelper.GetInteger("Which Campground (enter 0 to cancel):"); bool returnToPrevious = campground == int.Parse(command_Cancel); //Return to previous screen if user enters 0 if (returnToPrevious) { return; } while (!campgrounds.ContainsKey(campground)) { campground = campground = CLIHelper.GetInteger("Invalid choice. Please pick a campground Site number from available list:"); } ; bool stillBooking = false; do { DateTime startDate = CLIHelper.GetDateTime("Enter start date (YYYY/MM/DD):"); DateTime endDate = CLIHelper.GetDateTime("Enter end date (YYYY/MM/DD):"); var availableSites = campgroundDAL.GetCampgroundAvailability(campgrounds[campground].Name, startDate, endDate); if (availableSites.Count > 0) { List <int> availableSiteNumbers = new List <int>(); int totalReservDays = (int)(endDate - startDate).TotalDays; Console.Clear(); Console.WriteLine("Results Matching Your Search Criteria"); Console.WriteLine(String.Format("").PadRight(30, '=')); Console.WriteLine("{0,3}{1,12}{2,13}{3,14}{4,9}{5,10}{6,7}", "Campground", "Site No.", "Max Occup.", "Accessible?", "RV Len", "Utility", "Cost"); foreach (var site in availableSites) { double cost = campgrounds[campground].Daily_Fee * totalReservDays; availableSiteNumbers.Add(site.SiteNumber); Console.WriteLine(campgrounds[campground].Name.PadRight(17) + site.SiteNumber.ToString().PadRight(12) + site.MaxOccupancy.ToString().PadRight(13) + site.WheelchairAccess.PadRight(11) + site.MaxRVLength.PadRight(10) + site.UtilityHookups.PadRight(9) + cost); } bool reservationSuccessful = BookReservation(availableSiteNumbers, startDate, endDate); if (reservationSuccessful) { stillBooking = false; } } else { Console.WriteLine("Sorry, there are no sites available in the specified date range."); stillBooking = CLIHelper.GetBoolFromYesOrNo("Would you like to enter another date range?"); } } while (stillBooking); }
private void GetParkWideAvailability(string parkName) { CampgroundSqlDAL campgroundDAL = new CampgroundSqlDAL(); Dictionary <int, Campground> campgrounds = campgroundDAL.GetAllCampgroundsInPark(parkName); Console.Clear(); DateTime startDate = CLIHelper.GetDateTime("What is the arrival date (YYYY/MM/DD)?:"); DateTime endDate = CLIHelper.GetDateTime("What is the departure date (YYYY/MM/DD)?:"); List <Site> availableSites = campgroundDAL.GetParkAvailability(parkName, startDate, endDate); if (availableSites.Count > 0) { Console.Clear(); Console.WriteLine("Results Matching Your Search Criteria"); Console.WriteLine("{0,13}{1,12}{2,13}{3,14}{4,9}{5,10}{6,7}", "Campground", "Site No.", "Max Occup.", "Accessible?", "RV Len", "Utility", "Cost"); List <int> availableSiteNumbers = new List <int>(); int totalReservDays = (int)(endDate - startDate).TotalDays; foreach (var site in availableSites) { Campground campground = campgrounds.Where(i => i.Value.CampgroundId == site.CampgroundID).First().Value; availableSiteNumbers.Add(site.SiteNumber); double cost = totalReservDays * campground.Daily_Fee; Console.WriteLine(campground.Name.PadRight(13) + site.SiteNumber.ToString().PadRight(12) + site.MaxOccupancy.ToString().PadRight(13) + site.WheelchairAccess.PadRight(19) + site.MaxRVLength.PadRight(9) + site.UtilityHookups.PadRight(10) + cost); } BookReservation(availableSiteNumbers, startDate, endDate); } else { Console.WriteLine("Sorry, there are no sites available in the specified date range."); bool stillBooking = CLIHelper.GetBoolFromYesOrNo("Would you like to enter another date range?"); } }