public void DatesPrompt(int campgroundId, Park selectedPark) { string fromDate; string toDate; bool isDone = false; CampsiteDAL campsiteDAL = new CampsiteDAL(connectionString); CampgroundDAL campgroundDAL = new CampgroundDAL(connectionString); List <Campsite> campsites; try { do { Console.WriteLine("\nWhat is the arrival date? (yyyy-mm-dd)"); fromDate = Console.ReadLine(); Console.WriteLine("\nWhat is the departure date? (yyyy-mm-dd)"); toDate = Console.ReadLine(); if (!AreDatesInFuture(fromDate, toDate) || !ArriveBeforeDepartCheck(fromDate, toDate)) { Console.WriteLine(""); Console.WriteLine("Sorry, those are not valid dates."); } else if (!campgroundDAL.CampgroundCheck(campgroundId, selectedPark.Id, fromDate, toDate)) { Console.WriteLine(""); Console.WriteLine("Sorry, the campground is not open during those dates."); } else { isDone = true; } }while (!isDone); campsites = campsiteDAL.GetCampsites(campgroundId, fromDate, toDate); if (campsites.Count == 0) { NoCampsitesAvailablePrompt(campsites); } else { DisplayAvailableReservations(campsites, toDate, fromDate); DisplayCreateReservationMenu(campsites, fromDate, toDate); } } catch (Exception ex) { Console.WriteLine(); Console.WriteLine("Not a valid value- please try again"); } }
public void TestAvailableCampsites() { CampsiteDAL campsiteDAL = new CampsiteDAL(connectionString); List <Campsite> campsites = campsiteDAL.GetCampsites(1, "2019-10-10", "2019-10-12"); bool result = false; for (int i = 0; i < campsites.Count; i++) { if (campsites[i].SiteId == 1) { result = true; } } Assert.AreEqual(true, result); }
public void Reservation_Fail() { ReservationDAL reservationDAL = new ReservationDAL(connectionString); CampsiteDAL campsteDAL = new CampsiteDAL(connectionString); List <Campsite> campsites = campsteDAL.AllAvailableCampsites(1, "2018-12-12", "2018-12-14"); bool result = false; if (campsites.Count > 1) { if (reservationDAL.CreateReservation(1, "Hart Family", "2018-12-12", "2018-12-14") > 1) { result = true; } } Assert.AreEqual(false, result); }