public void GetCampSiteAvailablity_Test() { List <Campsite> output = s.GetCampsitesByAvailability(connectionString, cg, fromDate, toDate); List <Campsite> output2 = s.GetCampsitesByAvailability(connectionString, cg2, fromDate, toDate); List <Campsite> output3 = s.GetCampsitesByAvailability(connectionString, cg3, fromDate, toDate); int result = output.Count; int result2 = output2.Count; int result3 = output3.Count; Assert.AreEqual(12, result); Assert.AreEqual(8, result2); Assert.AreEqual(5, result3); }
private static void CreateReservationMenu(string selectedCampground, List <Campground> campgrounds, Campground campground, DateTime arrival, DateTime departure, string connectionString) { PrintMenuDoubleSpaced(new[] { campground.Name + " Campground" }); PrintTrees(); Console.WriteLine(); List <Campsite> availableCampsites = campsiteDAL.GetCampsitesByAvailability(connectionString, campground, arrival, departure); if (availableCampsites.Count == 0) { Console.Clear(); PrintMenuDoubleSpaced(new[] { "I'm sorry, there are no available dates for your selected visit, please select again..." }); CheckReservationAvailabilityMenu(campgrounds, selectedCampground); } Console.SetCursorPosition((Console.WindowWidth - 80) / 2, Console.CursorTop); Console.WriteLine("{0, -15}{1, -15}{2, -15}{3, -15}{4, -15}{5, -15}", $"Site No.", $"Max Occup.", $"Accessible?", $"Max RV Length", $"Utility", $"Cost"); Console.WriteLine(); foreach (var site in availableCampsites) { decimal totalCost = campsiteDAL.CalculateCostOfReservation(site, arrival, departure, connectionString); Console.SetCursorPosition((Console.WindowWidth - 80) / 2, Console.CursorTop); Console.WriteLine("{0, -15}{1, -15}{2, -15}{3, -15}{4, -15}{5, -15}", $"{site.SiteID}", $"{site.MaxOccupancy}", $"{site.Accessible}", $"{site.MaxRvLength}", $"{site.Utilities}", $"{totalCost.ToString("c")}"); } Console.WriteLine(); Campsite reservationSite = new Campsite();//create a new campsite so that the user can book their stay PrintTreesBottom(); int userSelectedSiteID = CLIHelper.GetInteger("What site should be reserved?(To Return to the Main Menu press (0))"); //first verify that the site_id entered exists from the list provided to the user only! bool exists = availableCampsites.Any(x => x.SiteID == userSelectedSiteID); if (userSelectedSiteID == 0) { Console.Clear(); MainMenu(); } else if (exists) { reservationSite.SiteID = userSelectedSiteID; //book a reservation based on the site_id } else { Console.Clear(); Console.WriteLine("That is not a valid option, please select from the choices below..."); CreateReservationMenu(selectedCampground, campgrounds, campground, arrival, departure, connectionString); } string nameOfReservation = CLIHelper.GetString("What name should the reservation be placed under?"); if (availableCampsites.Any(x => x.SiteID == userSelectedSiteID)) { campsiteDAL.CreateReservation(reservationSite.SiteID, arrival, departure, nameOfReservation, connectionString); Console.WriteLine($"The reservation has been created and the reservation id is " + $"{campsiteDAL.GetReservationID(reservationSite.SiteID, connectionString)}"); Console.WriteLine("Press Enter to Return to the Main Menu"); Console.ReadLine(); MainMenu(); } else { // if the site has not been reserved on the provided dates the reservation will be created Console.WriteLine("This site is already reserved during the dates provided"); CheckReservationAvailabilityMenu(campgrounds, selectedCampground); } }