public void GetParkAvailabilityTest() { //Arrange CampgroundSqlDAL campgroundSqlDAL = new CampgroundSqlDAL(); DateTime dt1 = new DateTime(2018, 3, 3, 0, 0, 0); DateTime dt2 = new DateTime(2018, 3, 5, 0, 0, 0); //Act List <Site> sites = campgroundSqlDAL.GetParkAvailability("Acadia", dt1, dt2); //Assert Assert.AreEqual(5, sites.Count); }
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?"); } }