private void SitesResultsMenu(Park selectedPark, Campground campgroundChoice, string[] reservationDates, decimal dailyFee) { IList <Site> sites = siteDAO.GetAvailableReservationsSingleCapmground(campgroundChoice.CampgroundId, reservationDates[0], reservationDates[1]); int siteChoice = -1; Console.WriteLine("Results Matching Your Search Criteria"); Console.WriteLine(String.Format("{0,-40} {1, -20} {2,-20} {3,-20} {4,-20} {5,-20}", "Site No.", "Max Occup.", "Accessible?", "Max RV Length", "Utility", "Cost")); Console.WriteLine(); for (int i = 0; i < sites.Count; i++) { Console.WriteLine(String.Format("{0,-40} {1, -20} {2,-20} {3,-20} {4,-20} {5,-20}", sites[i].SiteNumber, sites[i].MaxOccupancy, sites[i].Accessible, sites[i].MaxRVLength, sites[i].Utilities, dailyFee)); } Console.WriteLine(); while (siteChoice < 1 || siteChoice > sites.Count) { Console.Write("Which site should be reserved (enter 0 to cancel)?"); if (int.TryParse(Console.ReadLine(), out siteChoice)) { if (siteChoice == 0) { return; } foreach (Site site in sites) { if (site.SiteNumber == siteChoice) { Console.Write("What name should the reservation be made under?"); string customerName = Console.ReadLine(); reservationDAO.MakeAReservation(site, customerName, reservationDates[0], reservationDates[1]); return; } } } else { Console.WriteLine("Invalid Input. Please enter a valid number."); } } }
private int MakeReservation(int site, string campersName, DateTime fromDate, DateTime toDate) { int reservationId = reservationDAO.MakeAReservation(site, campersName, fromDate, toDate); return(reservationId); }