public void GetAllSitesCampgroundTest() { SiteDAL testObj = new SiteDAL(connectionString); List <Site> sites = testObj.GetAvailableSitesCampground(campgroundID, DateTime.Today, DateTime.Today); Assert.AreEqual(1, sites.Count); }
public void MakeReservation(int parkID, int campgroundID) { bool searchAgain = false; SiteDAL siteDAL = new SiteDAL(connectionString); List <Site> availableSites = new List <Site>(); DateTime fromDate; DateTime toDate; do { searchAgain = false; fromDate = CLIHelper.GetDateTime("What is the arrival date: "); int numberOfAttempts = 0; do { if (numberOfAttempts > 0) { Console.WriteLine("Departure date cannot be before/equal to arrival date."); } toDate = CLIHelper.GetDateTime("What is the departure date: "); numberOfAttempts++; } while (toDate.CompareTo(fromDate) <= 0); Console.WriteLine(); Console.WriteLine("".PadRight(4) + "Campground".PadRight(35) + "Site No.".PadRight(10) + "Max Occup.".PadRight(12) + "Accessible?".PadRight(15) + "RV Len".PadRight(10) + "Utilities".PadRight(11) + "Cost"); if (campgroundID == 0) { availableSites = siteDAL.GetAvailableSitesPark(parkID, toDate, fromDate); } else { availableSites = siteDAL.GetAvailableSitesCampground(campgroundID, toDate, fromDate); } if (availableSites.Count == 0) { Console.WriteLine("There are no available sites."); string askSearchAgain = CLIHelper.GetString("Do you wish to search again? "); switch (askSearchAgain.ToLower()) { case "y": searchAgain = true; break; default: Console.WriteLine("Thank you, you will be returned to the Park Selection screen. Press enter to continue..."); Console.ReadLine(); return; } } } while (searchAgain); TimeSpan interval = toDate.Date.Subtract(fromDate); int numDays = 1 + interval.Days; int index = 1; foreach (Site s in availableSites) { Console.WriteLine(index.ToString().PadRight(4) + s.ToString(numDays)); index++; } ; int siteToBook = CLIHelper.GetInteger("Which site should be reserved (enter 0 to cancel): "); bool invalidSelection = false; do { if (siteToBook == 0) { invalidSelection = false; Console.WriteLine("Thank you, you will be returned to the Park Selection screen. Press enter to continue..."); Console.ReadLine(); } else if (siteToBook > 0 && siteToBook < index) { ReservationDAL reservationDAL = new ReservationDAL(connectionString); string nameToBook = CLIHelper.GetString("What name should the reservation be made under? "); int confirm = reservationDAL.CreateReservation(availableSites[siteToBook - 1].SiteID, nameToBook, fromDate, toDate); Console.WriteLine($"\nThe reservation has been made and the confirmation id is {confirm}."); Console.WriteLine("Press enter to continue..."); Console.ReadLine(); invalidSelection = false; } else { siteToBook = CLIHelper.GetInteger("Please enter a valid selection: "); invalidSelection = true; } } while (invalidSelection); return; }