public void SiteMenu() { campgroundId = CampgroundIdForReservation(); fromDate = ReservationFromDate(); toDate = ReservationToDate(); IList <Site> eligibleSites = siteDAO.GetSites(campgroundId, fromDate, toDate); GetSites(campgroundId, fromDate, toDate); }
/// <summary> /// Runs the menu /// </summary> public override void Run() { IList <Campground> campgrounds = campgroundDAO.GetCampgrounds(park.Id); CampgroundMenuHeader(campgrounds); DisplayCampgroundOptions(); while (true) { int userInput = GetInteger("Pick One:", 0, campgrounds.Count); if (userInput == 1) { CampgroundMenuHeader(campgrounds); int selectedCampground = GetInteger("Which campground (enter 0 to cancel)?", -1, campgrounds.Count); if (selectedCampground == 0) { break; } DateTime arrivalDate = GetDate("What is the arrival date (mm/dd/yyyy)?"); DateTime departureDate = GetDate("What is the departure date (mm/dd/yyyy)?"); Console.WriteLine(); // List of all Avaiable sites IList <Site> sites = siteDAO.GetSites(campgrounds[selectedCampground - 1].Id, arrivalDate, departureDate); // Displays site results Console.WriteLine("Site No.".PadRight(sitePad) + "Max Occup.".PadRight(sitePad) + "Accessible?".PadRight(sitePad) + "Max RV Length".PadRight(sitePad) + "Utilty".PadRight(sitePad) + "Cost"); foreach (Site site in sites) { decimal cost = campgroundDAO.GetCampingCost(campgrounds[selectedCampground - 1].DailyFee, arrivalDate, departureDate); Console.WriteLine($"{site.SiteNumber,-sitePad}{site.MaxOccupancy,-sitePad}{site.Accessible,-sitePad}{site.MaxRVLength,-sitePad}{site.Utilities,-sitePad}{cost:C2}"); } // Book reservation Console.WriteLine(); int siteNumber = GetInteger("Which site should be reserved (enter 0 to cancel)?"); string reservationName = GetString("What name should the reservation be made under?"); reservationDAO.GetReservations(sites[siteNumber - 1].SiteId); Reservation newReservation = CreateReservation(sites[siteNumber - 1].SiteId, arrivalDate, departureDate, reservationName); int reservationId = reservationDAO.BookResrevation(newReservation); Console.Write($"The reservation has been made and the confirmation id is {reservationId}"); Console.ReadLine(); CampgroundMenuHeader(campgrounds); DisplayCampgroundOptions(); } else if (userInput == 2) { break; } else { InvalidInput(); } } }
protected override bool ExecuteSelection(string choice) { decimal totalCost; DateTime arrivalDate; DateTime departureDate; int siteReservation; string nameReservation; int reservationID; switch (choice)// choice indicates campground { case "1": // user will get prompted for arrival and departure dates Console.WriteLine("What is your arrival date MM/DD/YYYY"); arrivalDate = DateTime.Parse(Console.ReadLine()); Console.WriteLine("What is your departure date MM/DD/YYYY"); //*****************Logic to ensure date in the future departureDate = DateTime.Parse(Console.ReadLine()); siteList = siteDAO.GetSites(arrivalDate, departureDate, campgroundList[0].Campground_Id); // user will see results matching their search (Sites) Console.WriteLine($"{"SiteNo.", -15} {"Max Occup.", -15} {"Accesible?", -15} {"MaxRvLength",-15} {"Utility", -15} {"Cost",-15}"); foreach (Site site in siteList) { totalCost = site.TotalCost(arrivalDate, departureDate, campgroundList[0].Daily_Fee); Console.WriteLine($"{site.Site_Number, -15} {site.Max_Occupancy, -15} {site.Accessible, -15} {site.Max_Rv_Length, -15} {site.Utilities, -15} {totalCost, -15:C}"); } Console.WriteLine("What site should be reserved (Please enter site number)?"); siteReservation = int.Parse(Console.ReadLine()); Console.WriteLine("What name should the reservation be made under?"); nameReservation = Console.ReadLine(); reservationID = reservationDAO.AddReservation(siteReservation, nameReservation, arrivalDate, departureDate); Console.WriteLine($"Thank you for your reservation! {nameReservation} has made a reservation at site {siteReservation} from {arrivalDate.ToShortDateString()} to {departureDate.ToShortDateString()}." + $"Your reservation ID is {reservationID}."); Pause(""); return(true); case "2": // user will get prompted for arrival and departure dates Console.WriteLine("What is your arrival date MM/DD/YYYY"); arrivalDate = DateTime.Parse(Console.ReadLine()); Console.WriteLine("What is your departure date MM/DD/YYYY"); departureDate = DateTime.Parse(Console.ReadLine()); siteList = siteDAO.GetSites(arrivalDate, departureDate, campgroundList[1].Campground_Id); // user will see results matching their search (Sites) Console.WriteLine($"{"SiteNo.",-15} {"Max Occup.",-15} {"Accesible?",-15} {"MaxRvLength",-15} {"Utility",-15} {"Cost",-15}"); foreach (Site site in siteList) { totalCost = site.TotalCost(arrivalDate, departureDate, campgroundList[1].Daily_Fee); Console.WriteLine($"{site.Site_Number,-15} {site.Max_Occupancy,-15} {site.Accessible,-15} {site.Max_Rv_Length,-15} {site.Utilities,-15} {totalCost,-15:C}"); } Console.WriteLine("What site should be reserved (Please enter site number)?"); siteReservation = int.Parse(Console.ReadLine()); Console.WriteLine("What name should the reservation be made under?"); nameReservation = Console.ReadLine(); reservationID = reservationDAO.AddReservation(siteReservation, nameReservation, arrivalDate, departureDate); Console.WriteLine($"Thank you for your reservation! {nameReservation} has made a reservation at site {siteReservation} from {arrivalDate.ToShortDateString()} to {departureDate.ToShortDateString()}." + $"Your reservation ID is {reservationID}."); Pause(""); return(true); case "3": // user will get prompted for arrival and departure dates Console.WriteLine("What is your arrival date MM/DD/YYYY"); arrivalDate = DateTime.Parse(Console.ReadLine()); Console.WriteLine("What is your departure date MM/DD/YYYY"); departureDate = DateTime.Parse(Console.ReadLine()); siteList = siteDAO.GetSites(arrivalDate, departureDate, campgroundList[2].Campground_Id); // user will see results matching their search (Sites) Console.WriteLine($"{"SiteNo.",-15} {"Max Occup.",-15} {"Accesible?",-15} {"MaxRvLength",-15} {"Utility",-15} {"Cost",-15}"); foreach (Site site in siteList) { totalCost = site.TotalCost(arrivalDate, departureDate, campgroundList[2].Daily_Fee); Console.WriteLine($"{site.Site_Number,-15} {site.Max_Occupancy,-15} {site.Accessible,-15} {site.Max_Rv_Length,-15} {site.Utilities,-15} {totalCost,-15:C}"); } Console.WriteLine("What site should be reserved (Please enter site number)?"); siteReservation = int.Parse(Console.ReadLine()); Console.WriteLine("What name should the reservation be made under?"); nameReservation = Console.ReadLine(); reservationID = reservationDAO.AddReservation(siteReservation, nameReservation, arrivalDate, departureDate); Console.WriteLine($"Thank you for your reservation! {nameReservation} has made a reservation at site {siteReservation} from {arrivalDate.ToShortDateString()} to {departureDate.ToShortDateString()}." + $"Your reservation ID is {reservationID}."); Pause(""); return(true); } // user will get prompted for site and name (Method to confirm **Check and Insert reservation) return(true); }