public void SearchMatchingAvailSites(UserReservation userReservation) { sites = siteConnect.GetAvailableSites(userReservation); for (int i = 0; i < campgrounds.Count; i++) { if (campgrounds[i].CampgroundId == userReservation.CampgroundID) { userReservation.CampName = campgrounds[i].CampgroundName; Console.Clear(); Console.WriteLine($"{userReservation.CampName} has the following campsites:"); Console.WriteLine("Site No.".PadRight(15) + "Max Occup.".PadRight(15) + "Accessible".PadRight(15) + "Max RV Length".PadRight(25) + "Utility".PadRight(15) + "Cost"); ShowSites(sites, userReservation, campgrounds[i].DailyFee); } } Console.WriteLine(); int siteInput = CLIHelper.GetInteger("Please choose the site number you would like to book (or 0 to cancel).", sites.Count, true); if (siteInput == 0) { Quit(); } else { ReserveSite(userReservation); } }
public void ReserveSite(UserReservation reservation) { bool isNotNull = true; string nameOfReservation; do { Console.WriteLine("What name should the reservation be made under?"); nameOfReservation = Console.ReadLine(); if (String.IsNullOrEmpty(nameOfReservation)) { isNotNull = false; Console.WriteLine("You must enter a name to proceed with this reservation."); Console.WriteLine(); } } while (!isNotNull); int confirmationId = reserve.CreateReservation(reservation.SiteID, nameOfReservation, reservation.ArrivalDate, reservation.DepartureDate); Console.WriteLine($"The reservation has been made and the confirmation id is {confirmationId}."); Console.WriteLine("Thank you for booking with us. Enjoy your stay!"); Console.WriteLine(); Console.WriteLine("Hit any key to exit this system."); Console.ReadKey(); Environment.Exit(0); }
public void ShowSites(List <Site> sites, UserReservation userReservation, decimal dailyCost) { int totalDays = (userReservation.DepartureDate - userReservation.ArrivalDate).Days; decimal totalCost = totalDays * dailyCost; for (int i = 0; i < sites.Count; i++) { Console.WriteLine(sites[i].ToString() + "$" + totalCost.ToString("#.##")); } }
public void SearchForCampgroundReservation() { string arrivalDateMessage = "\nWhat is the arrival date? (YYYY/MM/DD): "; string departureDateMessage = "\nWhat is the departure date? (YYYY/MM/DD): "; Console.WriteLine(); //int campgroundInput = CLIHelper.GetInteger("For which campground would you like to check reservations (0 to cancel)?", campgrounds.Count, true); int campgroundInput = 0; try { Console.WriteLine("For which campground would you like to check reservations (0 to cancel)?"); campgroundInput = int.Parse(Console.ReadLine()); } catch { Quit(); } if (campgroundInput == 0) { Quit(); } else { DateTime arrivalDate = CLIHelper.GetDateTime(arrivalDateMessage); DateTime departureDate = CLIHelper.GetDateTime(departureDateMessage); UserReservation userReservation = new UserReservation(campgroundInput, arrivalDate, departureDate); bool isInSeason = campgroundsSqlDAL.SearchInSeason(userReservation); if (!isInSeason) { Console.WriteLine($"{campgrounds[campgroundInput].CampgroundName} is not in season at the specified time frame."); } else { SearchMatchingAvailSites(userReservation); } Console.ReadKey(); } }