public void GetReservationInfo_Test() { ReservationSqlDAL dal = new ReservationSqlDAL(ConnectionString); Campground testCampground = new Campground(); testCampground.CampgroundID = 1; Site testSite = new Site(); testSite.SiteID = 1; dal.GetReservationInfo(testCampground); int rows = GetRowCount("reservation"); Assert.AreEqual(1, rows); }
public void ReservationSearch(Park park) { ViewAllCampgrounds(park); int campgroundId = CLIHelper.GetInteger("Which campground (enter 0 to cancel)? "); if (campgroundId == 0) { MainParkList(); } else { // List<Campground> campgrounds = campgroundSqlDAL.ViewAllCampgrounds(park); Campground campground = campgroundSqlDAL.GetCampgroundById(park, campgroundId); if (campgroundId != campground.CampgroundId) { Console.WriteLine("Sorry, that was an invalid input! Please start over!"); MainParkList(); } else { string arrivalDate = CLIHelper.GetString("What is the arrival date? MM/DD/YYYY"); string departureDate = CLIHelper.GetString("What is the departure date? MM/DD/YYYY"); int arrivalMonth = Int32.Parse(arrivalDate.Substring(0, 2)); int departureMonth = Int32.Parse(departureDate.Substring(0, 2)); int totalStay = (DateTime.Parse(departureDate) - DateTime.Parse(arrivalDate)).Days; if (((arrivalMonth >= campground.OpeningMonth) && (arrivalMonth <= campground.ClosingMonth)) && ((departureMonth >= campground.OpeningMonth) && (departureMonth <= campground.ClosingMonth))) { CampSiteSqlDAL dal = new CampSiteSqlDAL(DatabaseConnection); List <CampSite> campSites = dal.Search(campgroundId, arrivalDate, departureDate); if (campSites.Count > 0) { Console.WriteLine("Site No.".PadRight(20) + "Max Occup.".PadRight(20) + "Accessible?".PadRight(20) + "Max RV Length".PadRight(20) + "Utility".PadRight(20) + "Cost"); foreach (CampSite site in campSites) { Console.WriteLine(); Console.WriteLine(site.CampsiteNumber.ToString().PadRight(20) + site.MaxOccupancy.ToString().PadRight(20) + TranslateBoolAccessible(site.Accessible).PadRight(20) + TranslateRVLength(site.MaxRvLength).ToString().PadRight(20) + TranslateBoolUtilities(site.Utilities).PadRight(20) + site.DailyFee.ToString("C")); } Console.WriteLine(); Console.WriteLine($"Total cost for stay: ${totalStay * campground.DailyFee:00.00}"); Console.WriteLine(); int reservedSiteId = CLIHelper.GetInteger("Which site should be reserved (enter 0 to cancel)?"); bool exists = false; foreach (CampSite site in campSites) { if (site.SiteId == reservedSiteId) { exists = true; } } if (reservedSiteId == 0) { Console.Clear(); MainParkList(); } else if (exists) { string reservationName = CLIHelper.GetString("What name should the reservation be made under?"); Reservation r = reservationsqlDAL.GetReservationInfo(reservedSiteId, reservationName, arrivalDate, departureDate); GetReservationId(r); } else { Console.WriteLine("Sorry, that was an invalid input! Please start over!"); CampgroundMenu(); } } else { Console.WriteLine(); Console.WriteLine("**** BOOKED OUT!! ****"); Console.WriteLine("Please try another date or another campground."); Console.WriteLine(); ReservationSearch(park); } } else { Console.WriteLine(); Console.WriteLine("Sorry, campground is closed, LOSER!"); Console.WriteLine(); MainParkList(); } //Campground campground = campgroundSqlDAL.GetCampgroundById(park, campgroundId); //if (campgroundId != campground.CampgroundId) //{ // Console.WriteLine("Sorry, that was an invalid input! Please start over!"); // MainParkList(); //} } } }