public void ReturnNoSitesTest() { SiteSqlDAL testSite = new SiteSqlDAL(connectionString); List <Site> siteList = testSite.GetTopFiveSites(37, new System.DateTime(2018, 10, 15), new System.DateTime(2018, 10, 20)); Assert.AreEqual(0, siteList.Count); }
//Checks with current reservations to see if site is available public bool AvailableSitesToReserve(int campgroundID, string arrivalDate, string departureDate) { int reservationId = 0; DateTime arrivalResult = DateTime.MinValue; DateTime departureResult = DateTime.MinValue; DateTime.TryParse(arrivalDate, out arrivalResult); DateTime.TryParse(departureDate, out departureResult); SiteSqlDAL dal = new SiteSqlDAL(connectionString); List <Site> site = dal.GetTopFiveSites(campgroundID, arrivalResult, departureResult); if (site.Count == 0) { Console.WriteLine(); Console.WriteLine("No availiable sites to reserve"); return(true); } Console.WriteLine(); Console.WriteLine("Results Matching Your Search Criteria"); Console.WriteLine("Site No. Max Occup. Accessible? Max RV Length Utility Cost"); foreach (Site sites in site) { string result; result = sites.Id.ToString().PadRight(11); result += sites.MaxOcc.ToString().PadRight(13); if (sites.Accessible == false) { result += "No".PadRight(14); } else { result += "Yes".PadRight(14); } if (sites.RVLength > 0) { result += sites.RVLength.ToString().PadRight(16); } else { result += "N/A".PadRight(16); } if (sites.Utilities == false) { result += "No".PadRight(10); } else { result += "Yes".PadRight(10); } result += "$" + sites.totalCost; Console.WriteLine(result); } int siteNumber = CLIHelper.GetInteger("Which site should be reserved? (enter 0 to cancel)"); if (siteNumber == 0) { Console.WriteLine("Hope to have you stay next time!"); return(false); } else if (siteNumber < 0) { Console.WriteLine("Please select valid site number"); Console.WriteLine(); return(true); } string nameToBook = CLIHelper.GetString("What name should the reservation be made under? "); ReservationSQLDal newDAL = new ReservationSQLDal(connectionString); reservationId = newDAL.MakeReservation(siteNumber, nameToBook, arrivalDate, departureDate); Console.WriteLine($"{nameToBook} The reservation has been made and the confirmation id is {reservationId}"); Console.WriteLine(); Console.WriteLine("Would you like to make another reservation? If so press enter to return to park menu"); Console.ReadLine(); return(true); }