private void ViewParkDetails() { int parkToView = CLIHelper.GetInteger("What park would you like to view?"); Console.WriteLine(); NationalParkDAL npDAL = new NationalParkDAL(DatabaseConnection); Park p = npDAL.GetParkInfo(parkToView); if (p != null) { Console.WriteLine("Park ID: " + p.Id); Console.WriteLine("Park Name: " + p.name); Console.WriteLine("Location: " + p.location); Console.WriteLine("Established: " + p.establishdate); Console.WriteLine("Area: " + p.area); Console.WriteLine("Visitors " + p.visitors); Console.WriteLine(p.description); ParkSubmenu(p.Id); } else { Console.WriteLine("NO RESULTS IN PARKLIST"); } }
public void DisplayParkInformation(string name) { ParkSqlDAL parkSqlDAL = new ParkSqlDAL(); Park park = parkSqlDAL.GetParkInfo(name); Console.WriteLine(); PrintTitleScreen("Park Information Screen"); Console.WriteLine("Name:".PadRight(17) + park.Name); Console.WriteLine("Location:".PadRight(17) + park.Location); Console.WriteLine("Established:".PadRight(17) + park.EstablishDate.ToString("yyyy-MM-dd")); Console.WriteLine("Area:".PadRight(17) + park.Area.ToString("N0") + (" acres")); Console.WriteLine("Annual Visitors:".PadRight(17) + park.AnnualVisitorCount.ToString("N0")); Console.WriteLine("Description:".PadRight(17)); List <string> description = ReformatLargeText(park.Description); for (int i = 0; i < description.Count; i++) { if (i == 0) { Console.WriteLine(description[i]); } Console.WriteLine(description[i]); } }
public static Park SelectFrom(List <Park> someParks) { Park output = new Park(); Console.Clear(); Console.WriteLine("\tPark Name"); foreach (Park item in someParks) { int position = someParks.IndexOf(item) + 1; Console.Write($"[{position}]\t"); Console.WriteLine(item.name); } while (output.selected == false) { string input = Console.ReadKey(true).KeyChar.ToString(); int.TryParse(input, out int x); if (0 < x && x <= someParks.Count) { output = someParks[x - 1]; output.selected = true; } } return(output); }
private void DisplayReservationMenu(Park park) { bool exit = false; while (!exit) { Console.Clear(); Console.WriteLine(); Console.WriteLine("Search for Campground Reservation"); Console.WriteLine(); Console.WriteLine(string.Format("{0, -4}{1, -20}{2, -20}{3, -20}{4, -20}", "", "Name", "Open", "Close", "Daily Fee")); DisplayCampgrounds(park); Console.WriteLine(); int campgroundId = CLIHelper.GetInteger("Choose a campground ? (enter 0 to cancel)"); if (campgroundId == 0) { exit = true; } else { while (!exit) { _arrivalDate = CLIHelper.GetDate("What is the arrival date? (MM/DD/YYYY)"); exit = ValidateArrivalDate(_arrivalDate); } exit = false; while (!exit) { _departureDate = CLIHelper.GetDate("What is the departure date? (MM/DD/YYYY)"); exit = ValidateDepartureDate(_departureDate); } exit = false; int numDays = (int)(_departureDate - _arrivalDate).TotalDays + 1; decimal totalCost = CalculateCost(campgroundId, numDays); while (!exit) { Console.WriteLine(); Console.WriteLine(string.Format("{0, -10}{1, -22}{2, -20}{3, -20}{4, -20}{5, -20}", "Site No.", "Max Occup.", "Max RV Length", "Accessible?", "Utilities", "Cost")); DisplayCampgroundSites(campgroundId, _arrivalDate, _departureDate); Console.WriteLine(); int inputNum = CLIHelper.GetInteger("Which site should be reserved? (Enter 0 to cancel)"); if (inputNum == 0) { exit = true; } else { //Console.WriteLine("What name should the reservation be made under?"); //string resName = Console.ReadLine(); string resName = CLIHelper.GetString("What name should the reservation be made under?"); int confirmNum = _reservationDAL.BookReservation(inputNum, _arrivalDate, _departureDate, resName); Console.WriteLine(); Console.WriteLine(); Console.WriteLine($"The reservation has been made and the confirmation number is {confirmNum}"); Console.ReadKey(); Environment.Exit(0); } } } } }
/// <summary> /// Gets a list of all the campgrounds in a particular park /// </summary> /// <param name="park">Needs a Park class object as an argument</param> /// <returns>Returns a list of all campgrounds from a chosen park.</returns> public List <Campground> GetCampgroundList(Park park) { List <Campground> list = _db.GetAllCampgrounds(park.ParkID); return(list); }
void SiteSeach() { CampSqlDAL sqlParks = new CampSqlDAL(dbConnectionString); ReservationAndSite reservation = new ReservationAndSite(); Park park = MenuHelper.SelectFrom(sqlParks.GetParks()); Campground camp = MenuHelper.SelectFrom(sqlParks.GetCampgrounds(park)); bool correct = false; while (!correct) { Console.Clear(); Campground.DrawInfoHead(); camp.DrawInfo(); Console.WriteLine(); Console.Write("Arrival date: "); reservation.GetDate(true); Console.Clear(); Campground.DrawInfoHead(); camp.DrawInfo(); Console.WriteLine(); Console.Write("Departure date: "); reservation.GetDate(false); Console.Clear(); Campground.DrawInfoHead(); camp.DrawInfo(); Console.WriteLine(); Console.WriteLine($"Arrival date: " + reservation.startDate.ToShortDateString() + "\t Departure date: " + reservation.endDate.ToShortDateString()); correct = MenuHelper.GetConfirmation(); } ReservationAndSite selectedSite = MenuHelper.SelectFrom(sqlParks.GetSites(reservation.startDate, reservation.endDate, camp)); correct = false; while (!correct) { while (reservation.reservationName == null) { Console.Clear(); Campground.DrawInfoHead(); camp.DrawInfo(); Console.WriteLine(); Console.WriteLine($"Arrival date: " + reservation.startDate.ToShortDateString() + "\t Departure date: " + reservation.endDate.ToShortDateString()); Console.Write("Reservation Name: "); reservation.GetName(); } Console.Clear(); Campground.DrawInfoHead(); camp.DrawInfo(); Console.WriteLine(); Console.WriteLine($"Arrival date: " + reservation.startDate.ToShortDateString() + "\t Departure date: " + reservation.endDate.ToShortDateString()); Console.Write("Reservation Name: " + reservation.reservationName); Console.WriteLine(); correct = MenuHelper.GetConfirmation(); } reservation.siteId = selectedSite.siteId; int resID = sqlParks.MakeReservation(reservation); Console.WriteLine("Your confirmation number is: " + resID); MenuHelper.EnterToRelease(); }
//TODO Bonus : park wide availability. public void ParkWideReservations(Park park) { //calls GetAvailableSitesFromPark from SiteSqlDal }
/// <summary> /// Prints park information for a selected park /// </summary> /// <param name="park">Park object selection</param> private void PrintParkInfo(Park park) { Console.WriteLine("".PadRight(lineWidth, lineChar)); Console.WriteLine(park.ToString()); }
private void SearchForReservationMenu(Park selectedPark) { SiteSqlDAL siteSqlDAL = new SiteSqlDAL(connectionString); CampgroundSqlDAL campgroundDAL = new CampgroundSqlDAL(connectionString); List <Campground> campgrounds = campgroundDAL.GetCampgrounds(selectedPark); Console.WriteLine($"#:".PadRight(8) + "Campground Name".PadRight(41) + "Open From:".PadRight(16) + "Open To:".PadRight(16) + "Daily Fee".PadRight(5)); foreach (Campground campground in campgrounds) { Console.WriteLine(campground.ToString()); } Console.Write("Which campground? (enter 0 to cancel)"); result[0] = Console.ReadLine(); if (result[0] == "0") { input = "3"; return; } Console.Write("What is the arrival date? (MM/DD/YYYY)"); result[1] = Console.ReadLine(); Console.Write("What is the departure date? (MM/DD/YYYY)"); result[2] = Console.ReadLine(); bool validCampgroundId = int.TryParse(result[0], out int campground_id); bool validFromDate = DateTime.TryParse(result[1], out DateTime from_date); bool validToDate = DateTime.TryParse(result[2], out DateTime to_date); if (DateTime.Compare(from_date, to_date) >= 0) { Console.WriteLine("Invalid Input, departure date is before arrival date. Press Enter to try again."); Console.ReadLine(); return; } if (!validCampgroundId || !validFromDate || !validToDate) { Console.WriteLine("Invalid Input, Check Campground ID or Date Formats. Press Enter to try again."); Console.ReadLine(); return; } bool containsId = false; foreach (Campground campground in campgrounds) { if (campground.Campground_id == campground_id) { containsId = true; } } if (containsId) { reservation.Reservation_from_date = from_date; reservation.Reservation_to_date = to_date; input = "5"; } //else //{ // Console.Clear(); // Console.WriteLine("Invalid Input, Check Campground ID or Date Formats."); // Console.WriteLine(); // input = "4"; // Console.Clear(); //} }
public void ViewAllIndividualSites(Park park) { bool exit = false; while (!exit) { Console.Clear(); Console.WriteLine($"{park.Name} National Park\n"); Console.WriteLine($"| {"Campground ID".PadRight(15)} | " + $"| {"Campground Name".PadRight(35)} | " + $"| {"Month Open".PadRight(10)} | " + $"| {"Closing Month".PadRight(15)} | " + $"| {"Daily Fee".PadRight(10)} | "); Console.WriteLine(new string('-', 100)); Dictionary <int, Campground> CampgroundDictionary = _park.GetCampgroundDictionary(park); foreach (KeyValuePair <int, Campground> item in CampgroundDictionary) { Console.WriteLine($"| {item.Value.CampgroundID.ToString().PadRight(15)} | " + $"| {item.Value.CampgroundName.PadRight(35)} | " + $"| {item.Value.DisplayMonthOpen.ToString().PadRight(10)} | " + $"| {item.Value.DisplayMonthClose.ToString().PadRight(15)} | " + $"| {item.Value.DailyFee.ToString("C").PadRight(10)} |"); } Console.WriteLine("\n\nWhich campground? Enter a campgroundID or enter 0 to return."); var selection = Console.ReadKey().KeyChar.ToString(); if (selection == "0") { Console.Clear(); return; } try { int sel = int.Parse(selection); Campground camp = CampgroundDictionary[sel]; Dictionary <int, Site> SiteDictionary = _park.GetSiteDictionary(CampgroundDictionary[sel]); Console.Clear(); Console.WriteLine($"| {"Site Number".PadRight(15)} | " + $"| {"Max Occup.".PadRight(15)}" + $"| {"Accessible?".PadRight(15)} | " + $"| {"Max RVLength".PadRight(15)} | " + $"| {"Utility".PadRight(15)} | " + $"| {"Cost".PadRight(15)} "); Console.WriteLine(new string('-', 100)); foreach (KeyValuePair <int, Site> item in SiteDictionary) { Console.WriteLine($"| {item.Value.SiteNumber.ToString().PadRight(15)} | " + $"| {item.Value.MaxOccupancy.ToString().PadRight(15)}" + $"| {item.Value.Accessible.ToString().PadRight(15)} | " + $"| {item.Value.MaxRVLength.ToString().PadRight(15)} | " + $"| {item.Value.Utilities.ToString().PadRight(15)} | " + $"| {item.Value.TotalFee.ToString("C").PadRight(15)}"); } Console.WriteLine("Press any key to return"); Console.ReadKey(); Console.Clear(); } catch { Console.WriteLine(") Please only enter a valid selection."); Console.ReadKey(); Console.Clear(); } } }
public void SearchAllCamgrounds(Park park) { bool exit = false; while (!exit) { try { Console.Clear(); Console.WriteLine($"Please enter the reservation date information to search for open campsites at {park.Name}.\n "); Console.WriteLine("What is the arrival date? Enter date as: yyyy-mm-dd:"); string arrival = Console.ReadLine().ToString(); DateTime arr = DateTime.Parse(arrival); Console.WriteLine("What is the departure date? Enter date as: yyyy-mm-dd:"); string departure = Console.ReadLine().ToString(); DateTime dep = DateTime.Parse(departure); if (arr >= DateTime.Now && dep >= DateTime.Now) { List <Campground> list = _park.GetCampgroundList(park); Dictionary <int, Site> selectedSites = new Dictionary <int, Site>(); foreach (Campground camp in list) { Console.WriteLine($"| Campground: {camp.CampgroundName.ToString().PadRight(15)}"); Console.WriteLine("| Campsites:".PadRight(15)); Dictionary <int, Site> Sites = _park.GetSelectedSiteDictionary(camp, arrival, departure); Console.WriteLine($"| {"Site ID".PadRight(15)} | " + $"| {"Site Number".PadRight(15)} | " + $"| {"Max Occup.".PadRight(15)}" + $"| {"Accessible?".PadRight(15)} | " + $"| {"Max RVLength".PadRight(15)} | " + $"| {"Utility".PadRight(15)} |" + $"| {"Cost".PadRight(15)} "); Console.WriteLine(new string('-', 120)); foreach (KeyValuePair <int, Site> item in Sites) { selectedSites.Add(item.Key, item.Value); Console.WriteLine($"| {item.Key.ToString().PadRight(15)} | " + $"| {item.Value.SiteNumber.ToString().PadRight(15)} | " + $"| {item.Value.MaxOccupancy.ToString().PadRight(15)}" + $"| {item.Value.Accessible.ToString().PadRight(15)} | " + $"| {item.Value.MaxRVLength.ToString().PadRight(15)} | " + $"| {item.Value.Utilities.ToString().PadRight(15)} |" + $"| {item.Value.TotalFee.ToString("C")}".PadRight(15)); } } Console.WriteLine("Which site would you like to reserve? Enter the site ID to select, or enter 0 to return"); var selection = Console.ReadLine().ToString(); if (selection == "0") { Console.Clear(); return; } try { int sel = int.Parse(selection); if (selectedSites.ContainsKey(sel)) { Console.WriteLine("What name should the reservation be made under?"); string reservationName = Console.ReadLine(); int reservationID = _park.AddReservation(selectedSites[sel], reservationName, arrival, departure); Console.WriteLine($"you're reservation number is {reservationID}. Thanks!"); Console.ReadKey(); Console.Clear(); ViewParks(); } else { Console.WriteLine("Please only enter a site number that exists"); Console.ReadKey(); Console.Clear(); } } catch { Console.WriteLine("Please only enter a valid site number or 0 to return."); Console.ReadKey(); Console.Clear(); } } else { Console.WriteLine("Please enter future dates"); Console.ReadKey(); Console.Clear(); } } catch { Console.WriteLine("Please only inter a valid selection!"); Console.ReadKey(); Console.Clear(); } } }
public CampgroundsInterface(Park selectedPark) { this.selectedPark = selectedPark; }
public void SearchAvailableReservation(Park park) { bool exit = false; while (!exit) { Console.Clear(); Console.WriteLine($"{park.Name} National Park"); Console.WriteLine($"| {"Campground ID".PadRight(15)} | " + $"| {"Campground Name".PadRight(35)} | " + $"| {"Month Open".PadRight(10)} | " + $"| {"Closing Month".PadRight(15)} | " + $"| {"Daily Fee".PadRight(10)} | "); Console.WriteLine(new string('-', 100)); Dictionary <int, Campground> CampgroundDictionary = _park.GetCampgroundDictionary(park); foreach (KeyValuePair <int, Campground> item in CampgroundDictionary) { Console.WriteLine($"| {item.Value.CampgroundID.ToString().PadRight(15)} | " + $"| {item.Value.CampgroundName.PadRight(35)} | " + $"| {item.Value.DisplayMonthOpen.ToString().PadRight(10)} | " + $"| {item.Value.DisplayMonthClose.ToString().PadRight(15)} | " + $"| {item.Value.DailyFee.ToString("C").PadRight(10)} |"); } Console.WriteLine("Which campground (enter 0 to cancel)? __"); var selection = Console.ReadKey().KeyChar.ToString(); if (selection == "0") { Console.Clear(); return; } try { int sel = int.Parse(selection); if (CampgroundDictionary.ContainsKey(sel)) { Console.WriteLine(") What is the arrival date? Enter date as: yyyy-mm-dd:"); string arrival = Console.ReadLine().ToString(); DateTime arr = DateTime.Parse(arrival); Console.WriteLine("What is the departure date? Enter date as: yyyy-mm-dd:"); string departure = Console.ReadLine().ToString(); DateTime dep = DateTime.Parse(departure); if (arr >= DateTime.Now && dep >= DateTime.Now) { ViewAllSelectedSites(CampgroundDictionary[sel], arrival, departure); } else { Console.WriteLine("Please enter future dates"); Console.ReadKey(); Console.Clear(); } } else { Console.WriteLine(") Please only enter a valid campground number"); Console.ReadKey(); Console.Clear(); } } catch { Console.WriteLine(") Please only enter a valid campground and dates"); Console.ReadKey(); Console.Clear(); } } }
public SubMenuCLI(Park park) { this.Park = park; }
public void RunCLI() { string input = ""; string input2 = "2"; ParkSqlDAL dal = new ParkSqlDAL(connectionString); List <Park> parksList = dal.GetAllParks(); Park selectedPark = null; while (true) { GetParks(); //prints out the list of all possible parks to choose from input = Console.ReadLine(); Console.Clear(); if (input.ToUpper() == "Q") //if User selects to quit, program ends { return; } RestartDisplayPark: selectedPark = DisplayPark(input); if (selectedPark == null) { } //displays all information about a single park, unless the selected park is null else if (selectedPark != null) { input = null; while (input == null) { ParkInfoMenu(); // 3 options: view campgrounds, search reservation, or previous screen input = Console.ReadLine(); Console.Clear(); } } if (input == "1") { RestartViewCampGround: ViewCampgrounds(selectedPark); //all campgrounds of a selected park CamprgroundMenu(); // 2 options: search for reservation, previous screen input2 = Console.ReadLine(); Console.Clear(); if (input2 == "1") { if (SearchForReservationMenu(selectedPark)) { MakeReservationMenu(); } else { goto RestartViewCampGround; } } else if (input2 == "2") { goto RestartDisplayPark; } else { Console.WriteLine("Please select a valid menu option."); goto RestartViewCampGround; } } else if (input == "2") { // RestartReservationMenu: if (SearchForReservationMenu(selectedPark)) { MakeReservationMenu(); } else { // goto } } else if (input == "3") { } else { Console.WriteLine("please select a valid menu option."); Console.WriteLine(); } } }
public void ReservationSearch(Park park) { ViewAllCampgrounds(park); int campgroundId = CLIHelper.GetInteger("Which campground (enter 0 to cancel)? "); if (campgroundId == 0) { MainParkList(); } else { // List<Campground> campgrounds = campgroundSqlDAL.ViewAllCampgrounds(park); Campground campground = campgroundSqlDAL.GetCampgroundById(park, campgroundId); if (campgroundId != campground.CampgroundId) { Console.WriteLine("Sorry, that was an invalid input! Please start over!"); MainParkList(); } else { string arrivalDate = CLIHelper.GetString("What is the arrival date? MM/DD/YYYY"); string departureDate = CLIHelper.GetString("What is the departure date? MM/DD/YYYY"); int arrivalMonth = Int32.Parse(arrivalDate.Substring(0, 2)); int departureMonth = Int32.Parse(departureDate.Substring(0, 2)); int totalStay = (DateTime.Parse(departureDate) - DateTime.Parse(arrivalDate)).Days; if (((arrivalMonth >= campground.OpeningMonth) && (arrivalMonth <= campground.ClosingMonth)) && ((departureMonth >= campground.OpeningMonth) && (departureMonth <= campground.ClosingMonth))) { CampSiteSqlDAL dal = new CampSiteSqlDAL(DatabaseConnection); List <CampSite> campSites = dal.Search(campgroundId, arrivalDate, departureDate); if (campSites.Count > 0) { Console.WriteLine("Site No.".PadRight(20) + "Max Occup.".PadRight(20) + "Accessible?".PadRight(20) + "Max RV Length".PadRight(20) + "Utility".PadRight(20) + "Cost"); foreach (CampSite site in campSites) { Console.WriteLine(); Console.WriteLine(site.CampsiteNumber.ToString().PadRight(20) + site.MaxOccupancy.ToString().PadRight(20) + TranslateBoolAccessible(site.Accessible).PadRight(20) + TranslateRVLength(site.MaxRvLength).ToString().PadRight(20) + TranslateBoolUtilities(site.Utilities).PadRight(20) + site.DailyFee.ToString("C")); } Console.WriteLine(); Console.WriteLine($"Total cost for stay: ${totalStay * campground.DailyFee:00.00}"); Console.WriteLine(); int reservedSiteId = CLIHelper.GetInteger("Which site should be reserved (enter 0 to cancel)?"); bool exists = false; foreach (CampSite site in campSites) { if (site.SiteId == reservedSiteId) { exists = true; } } if (reservedSiteId == 0) { Console.Clear(); MainParkList(); } else if (exists) { string reservationName = CLIHelper.GetString("What name should the reservation be made under?"); Reservation r = reservationsqlDAL.GetReservationInfo(reservedSiteId, reservationName, arrivalDate, departureDate); GetReservationId(r); } else { Console.WriteLine("Sorry, that was an invalid input! Please start over!"); CampgroundMenu(); } } else { Console.WriteLine(); Console.WriteLine("**** BOOKED OUT!! ****"); Console.WriteLine("Please try another date or another campground."); Console.WriteLine(); ReservationSearch(park); } } else { Console.WriteLine(); Console.WriteLine("Sorry, campground is closed, LOSER!"); Console.WriteLine(); MainParkList(); } //Campground campground = campgroundSqlDAL.GetCampgroundById(park, campgroundId); //if (campgroundId != campground.CampgroundId) //{ // Console.WriteLine("Sorry, that was an invalid input! Please start over!"); // MainParkList(); //} } } }
private void ViewCampsInterface(Park selectedPark) { bool exit = false; while (!exit) { Console.Clear(); CampgroundDAO dao = new CampgroundDAO(_connectionString); IList <Campground> camps = dao.GetCampgrounds(selectedPark); int Campcount = 0; //Dictionary created for passing into Infromation into other Methods Dictionary <int, Campground> campDict = new Dictionary <int, Campground>(); if (camps.Count > 0) { Console.WriteLine($"{selectedPark.Name} National Park Campgrounds"); Console.WriteLine(); Console.WriteLine("".PadRight(3) + "Name".PadRight(35) + "Open".PadRight(18) + "Close".PadRight(18) + "Daily Fee"); foreach (Campground c in camps) { Console.WriteLine($"#{++Campcount} {c.Name.PadRight(35)} " + $"{c.OpenFromString.PadRight(18)} {c.OpenToString.PadRight(18)} {c.DailyFee.ToString("C")}"); campDict.Add(Campcount, c); } Console.WriteLine(); Console.WriteLine("Select a Command"); Console.WriteLine("1) Search for Available Reservation"); Console.WriteLine("2) Return to Previous Screen"); int selection = CLIHelper.GetSingleInteger("Selection... ", 1, 2); Console.WriteLine(); if (selection == 1) { Console.WriteLine("Which campground? (enter 0 to cancel)"); int choice = CLIHelper.GetSingleInteger("Selection... ", 0, camps.Count); Console.WriteLine(); if (choice == 0) { //Blank to just loop back. } else { SearchForReservationInterface(campDict[choice]); } } else if (selection == 2) { exit = true; } } else { Console.Clear(); Console.WriteLine("****** NO RESULTS ******"); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); exit = true; } } }
public BookingSubMenuCLI(Park park) { this.Park = park; }
public bool DisplayParkInfo(Park park) { bool reservationMade = false; while (true) { Console.Clear(); //Display park name Console.WriteLine(park.Name + " National Park"); //Dispaly park Location Console.WriteLine(); Console.WriteLine("Location: " + park.Location); //Display est date Console.WriteLine("Established: " + park.EstablishDate.ToShortDateString()); //Display area Console.WriteLine("Area: " + park.Area); //Display annual visitors Console.WriteLine("Annual Visitors: " + park.Visitors); //Display description Console.WriteLine(); Console.WriteLine(park.Description); Console.WriteLine(); Console.WriteLine("Select a Command"); Console.WriteLine(" 1) View campgrounds"); Console.WriteLine(" 2) View all reservations for this park in the next 30 days"); Console.WriteLine(" 3) Search for reservation"); Console.WriteLine(" 4) Return to previous screen"); string input = Console.ReadLine(); if (input == "1") { //instantiate a campground list CLI and call campground display method CampgroundListCLI campgroundList = new CampgroundListCLI(); reservationMade = campgroundList.DisplayCampgrounds(park.Id); if (reservationMade) { break; } } else if (input == "2") { ReservationDAL rDAL = new ReservationDAL(DatabaseConnection); IDictionary <int, Reservation> UpcomingReservations = rDAL.GetAllReservationsNextThirty(park.Id); if (UpcomingReservations.Count == 0) { Console.WriteLine("There are no reservations for this park within the next thirty days"); Console.Write("To return to a list of the parks, press Q "); string userInput = Console.ReadLine().ToLower(); if (userInput == "q") { break; } } else { Console.WriteLine(); Console.WriteLine("Here are all the reservations in the next thirty days at " + park.Name + " National Park"); Console.WriteLine("Site ID".PadRight(10) + "Name".PadRight(30) + "From Date".PadRight(15) + "To Date".PadRight(15) + "Creation Date".PadRight(15)); foreach (KeyValuePair <int, Reservation> reservation in UpcomingReservations) { Console.WriteLine( reservation.Value.SiteId.ToString().PadRight(10) + reservation.Value.Name.PadRight(30) + reservation.Value.FromDate.ToShortDateString().PadRight(15) + reservation.Value.ToDate.ToShortDateString().PadRight(15) + reservation.Value.CreateDate.ToShortDateString().PadRight(15)); } Console.Write("To return to a list of the parks, press Q "); string userInput = Console.ReadLine().ToLower(); if (userInput == "q") { break; } } } else if (input == "3") { DateTime fromDate; DateTime toDate; SiteSearchCLI siteSearch = new SiteSearchCLI(); siteSearch.ChooseACampground(out fromDate, out toDate); //Call site DAL and use GetSitesParkwide to give the user a dictionary of all //campsites in the park to select from SiteDAL dal = new SiteDAL(DatabaseConnection); try { IDictionary <int, Site> AvailableSites = dal.GetSitesParkwide(park.Id, fromDate, toDate); Console.WriteLine(); Console.WriteLine("Results Matching Your Search Criteria"); Console.WriteLine("Campground".PadRight(35) + "Site No.".PadRight(10) + "Max Occup.".PadRight(15) + "Accessible?".PadRight(15) + "Max RV Length".PadRight(15) + "Utility".PadRight(15) + "Cost".PadRight(15)); foreach (KeyValuePair <int, Site> site in AvailableSites) { Console.WriteLine( site.Value.CampgroundName.ToString().PadRight(35) + site.Value.SiteNumber.ToString().PadRight(10) + site.Value.MaxOccupancy.ToString().PadRight(15) + (site.Value.Accessible ? "Yes" : "No").PadRight(15) + (site.Value.MaxRv == 0 ? "N/A" : site.Value.MaxRv.ToString()).PadRight(15) + (site.Value.Utilities ? "Yes" : "No").PadRight(15) + (TotalDays(fromDate, toDate) * site.Value.DailyFee).ToString().PadRight(15)); } Console.Write("Which site should be reserved(enter 0 to cancel)? "); int siteToReserve = int.Parse(Console.ReadLine()); if (siteToReserve == 0) { Console.WriteLine("Returning to Park List"); Thread.Sleep(2000); break; } else if (AvailableSites.ContainsKey(siteToReserve)) { Console.Write("What name should the reservation be made under? "); string reservationName = Console.ReadLine(); //Call reservation Database ReservationDAL reservationdDal = new ReservationDAL(DatabaseConnection); int reservationId = reservationdDal.MakeAReservation(siteToReserve, fromDate, toDate, reservationName); Console.WriteLine("The reservation has been made"); Console.WriteLine($"The confirmation ID is : {reservationId}"); Console.WriteLine($"Press Enter to Return to Park List"); Console.ReadLine(); return(reservationMade = true); } else { Console.Write("Please enter a valid selection"); Thread.Sleep(2000); } } catch (Exception ex) { Console.WriteLine("Please enter a valid selection"); } } else if (input == "4") { break; } else { Console.WriteLine("Please enter a valid selection."); Thread.Sleep(2000); } } return(reservationMade); }
private void ParkReservationMenu(Park park) { Console.WriteLine("Would you like an advance search? Y/N"); if (Console.ReadLine().ToUpper() == "Y") { ParkReservationAdvanceMenu(park); } else { DateTime startDate; DateTime endDate; do { Console.WriteLine("What is the arrival date?"); while (!DateTime.TryParse(Console.ReadLine(), out startDate)) { DisplayInvalidOption(); } Console.WriteLine("What is the departure date?"); while (!DateTime.TryParse(Console.ReadLine(), out endDate)) { DisplayInvalidOption(); } if (DateTime.Compare(startDate, endDate) > 0) { Console.WriteLine("Please enter arrival date before departure date"); } } while (DateTime.Compare(startDate, endDate) > 0); List <CampgroundSite> sites = _campgroundDAO.GetSitesByParkIdAndResevationAvailability(park.ParkId, startDate, endDate); Console.WriteLine(); Console.WriteLine("Name | Site Number | Max Occupancy | Handicap Access | RV Length | Utilities | Daily Fee"); Console.WriteLine("----------------------------------------------------------------------------------------"); foreach (CampgroundSite campgroundSite in sites) { Site site = campgroundSite.site; Campground campground = campgroundSite.campground; Console.WriteLine($"{campground.Name} " + $"{site.SiteNumber} " + $"{site.MaxOccupancy} " + $"{site.HandicapAccessibility} " + $"{site.MaxRVLength} " + $"{site.HasUtilities} " + $"{campground.DailyFee * (int)(endDate - startDate).TotalDays}$0:00"); } bool looping = true; int input = -1; int siteIdTemp = -1; while (looping) { Console.WriteLine("Which Campground should be reserved (enter 0 to cancel)?"); string inputStrCampgroundName = Console.ReadLine(); if (inputStrCampgroundName == "0") { looping = false; } else { Console.WriteLine("What site number whould you like? "); string inputSiteNumer = Console.ReadLine(); if (int.TryParse(inputSiteNumer, out input)) { bool isSiteVaild = false; foreach (CampgroundSite campgroundSite in sites) { if (campgroundSite.campground.Name == inputStrCampgroundName && campgroundSite.site.SiteNumber == input) { siteIdTemp = campgroundSite.site.SiteId; isSiteVaild = true; } } if (isSiteVaild) { Reservation reservation = new Reservation() { SiteId = siteIdTemp, Name = _userMgr.User.LastName + ", " + _userMgr.User.FirstName, FromDate = startDate, ToDate = endDate, CreationDate = DateTime.Now }; reservation.ReservationId = _campgroundDAO.AddReservation(reservation, _userMgr.User); Console.WriteLine($"The reservation has been made and the confirmation id is {reservation.ReservationId} "); looping = false; } else { DisplayInvalidOption(); } } } } Console.ReadLine(); } }
private void ShowParkDetails(int key) { Park park = parkDAO.ShowParkDetails(key); MountainASCII(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine($" Thank you for selecting {park.name} National Park."); Console.WriteLine(); Console.WriteLine($" Below you'll see facts about {park.name} as well as a list of campgrounds:"); Console.ResetColor(); Console.WriteLine(); Console.WriteLine($" Location: {park.location}"); Console.WriteLine($" Established: {Convert.ToString(park.establish_date.ToShortDateString())}"); Console.WriteLine($" Area: {park.area} sq km"); Console.WriteLine($" Annual Visitors: {park.visitors}"); Console.ResetColor(); Console.WriteLine(); Console.WriteLine($"{park.description}"); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.DarkGreen; try { Console.WriteLine(" Would you like to: "); Console.ResetColor(); Console.WriteLine(); Console.WriteLine(" 1. Search for an availabile reservation"); Console.WriteLine(" 2. Return to the previous menu"); Console.WriteLine(" 3. See all reservations in the next 30 days"); Console.WriteLine(" Q. Return to the main menu"); Console.SetCursorPosition(8, 31); bool exit = false; while (!exit) { string choice = Console.ReadLine().ToLower(); if (choice == Command_Reservation) { Console.Clear(); ViewAllCampgrounds(park.park_id); } else if (choice == Command_PreviousMenu) { Console.Clear(); ViewAllParks(); } else if (choice == Command_30DaysReservations) { Console.Clear(); ViewReservationsNext30(); } else if (choice == Command_Quit) { RunCLI(); } else { Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(" That is not a valid option. Please press any key to try again."); Console.ReadKey(); Console.ResetColor(); Console.Clear(); ShowParkDetails(key); } } } catch (Exception) { Console.WriteLine(" That is not a valid option. Please press any key to return to the previous menu."); Console.ReadKey(); ViewAllParks(); } }
public void PrintParkMenu(int parkID) { bool done = false; int userInput = 0; while (!done) { ParkSQLDAL dal = new ParkSQLDAL(DatabaseConnection); Park park = dal.GetParkInformation(parkID); if (park.Location != null || park.Description != null) { PrintParkInformation(parkID); Console.WriteLine("Select a Command"); Console.WriteLine("1) View Campgrounds"); Console.WriteLine("2) Search For Reservation"); Console.WriteLine("3) Return to Previous Screen"); Console.WriteLine(); Console.Write("Selection: "); try { userInput = int.Parse(Console.ReadLine()); } catch (Exception) { userInput = 0; } switch (userInput) { case 1: PrintCampgrounds(parkID); PrintCampgroundMenu(parkID); break; case 2: SearchForReservation(parkID); break; case 3: done = true; break; default: Console.WriteLine(); Console.WriteLine("Invalid Input. Press enter to continue."); Console.WriteLine(); Console.ReadLine(); Console.WriteLine(); break; } } else { Console.WriteLine(); Console.WriteLine("Invalid Input. Press enter to continue."); Console.WriteLine(); Console.ReadLine(); Console.WriteLine(); done = true; } } }
private void DisplayParks() { int input = -1; List <Park> parks = _campgroundDAO.GetParks(); bool loopingParkMenu = true; while (loopingParkMenu) { Console.Clear(); Console.WriteLine("View Park Interface"); Console.WriteLine("Select a Park for Further Details"); int i = 1; foreach (Park park in parks) { Console.WriteLine($" ({i}) {park.Name}"); i++; } Console.WriteLine($" (Q) quit"); Console.WriteLine(); Console.Write("Please Pick a Park "); bool looppingSubMenu = true; while (looppingSubMenu) { string inputStr = Console.ReadLine().ToLower(); if (int.TryParse(inputStr, out input) && input <= parks.Count && input > 0) { input--; Park park = parks[input]; DisplayParkInformation(park); Console.WriteLine("Select a Command"); Console.WriteLine(" 1) View Campgrounds"); Console.WriteLine(" 2) Search for Reservation"); Console.WriteLine(" 3) Return to Previous Screen"); inputStr = Console.ReadLine().ToLower(); if (int.TryParse(inputStr, out input) && input > 0 && input < 4) { if (input == 1) { CampgroundMenu(park); looppingSubMenu = false; } else if (input == 2) { ReservationMenu(park); looppingSubMenu = false; } else if (input == 3) { looppingSubMenu = false; } } } else if (inputStr == Option_Quit) { looppingSubMenu = false; loopingParkMenu = false; } else { DisplayInvalidOption(); } } } Console.ReadLine(); }
public void SearchAllCamgrounds(Park park) { bool exit = false; while (!exit) { try { Console.Clear(); Console.WriteLine($"Please enter the reservation date information to search for open campsites at {park.Name}.\n "); Console.WriteLine("What is the arrival date? Enter date as: yyyy-mm-dd:"); string arrival = Console.ReadLine().ToString(); DateTime arr = DateTime.Parse(arrival); Console.WriteLine("What is the departure date? Enter date as: yyyy-mm-dd:"); string departure = Console.ReadLine().ToString(); DateTime dep = DateTime.Parse(departure); _park.ValidateReservationDates(dep, arr); Console.Clear(); Console.WriteLine($"Here are available campsites at {park.Name} Park between {arrival} and {departure}\n"); List <Campground> list = _park.GetCampgroundList(park); Dictionary <int, Site> selectedSites = new Dictionary <int, Site>(); foreach (Campground camp in list) { Console.WriteLine($"| Campground: {camp.CampgroundName.ToString().PadRight(15)}"); Console.WriteLine("| Campsites:".PadRight(15)); Dictionary <int, Site> Sites = _park.GetSelectedSiteDictionary(camp, arrival, departure); Console.WriteLine($"| {"Site ID".PadRight(15)} | " + $"| {"Site Number".PadRight(15)} | " + $"| {"Max Occup.".PadRight(15)}" + $"| {"Accessible?".PadRight(15)} | " + $"| {"Max RVLength".PadRight(15)} | " + $"| {"Utility".PadRight(15)} |" + $"| {"Cost".PadRight(15)} "); Console.WriteLine(new string('-', 120)); foreach (KeyValuePair <int, Site> item in Sites) { selectedSites.Add(item.Key, item.Value); Console.WriteLine($"| {item.Key.ToString().PadRight(15)} | " + $"| {item.Value.SiteNumber.ToString().PadRight(15)} | " + $"| {item.Value.MaxOccupancy.ToString().PadRight(15)}" + $"| {item.Value.Accessible.ToString().PadRight(15)} | " + $"| {item.Value.MaxRVLength.ToString().PadRight(15)} | " + $"| {item.Value.Utilities.ToString().PadRight(15)} |" + $"| {item.Value.TotalFee.ToString("C")}".PadRight(15)); } Console.WriteLine(); } bool exit2 = false; while (!exit2) { int selection = NationalPark.GetInteger("Which campsite would you like to make a reservation under? (enter 0 to cancel)?"); if (selection == 0) { Console.Clear(); exit = true; exit2 = true; } else if (selectedSites.ContainsKey(selection)) { Console.WriteLine("What name should the reservation be made under?"); string reservationName = Console.ReadLine(); int reservationID = _park.AddReservation(selectedSites[selection], reservationName, arrival, departure); Console.WriteLine($"you're reservation number is {reservationID}. Thanks!"); Console.ReadKey(); exit = true; exit2 = true; } else { Console.WriteLine("Please only enter a site number that exists"); } } } catch (InvalidArrivalDateException) { Console.WriteLine("Please only enter future dates."); Console.ReadKey(); } catch (InvalidDepartureDateException) { Console.WriteLine("Please only enter and end date that is after your arrival date."); Console.ReadKey(); } catch { Console.WriteLine("Please only enter the date in a valid format"); Console.ReadKey(); Console.Clear(); } } }
private void ParkReservationAdvanceMenu(Park park) { DateTime startDate; DateTime endDate; int numPeople = -1; int rvLength = -1; CampgroundDAO.AccessibleOptions accessible = CampgroundDAO.AccessibleOptions.either; CampgroundDAO.UtilitiesAvailble utilities = CampgroundDAO.UtilitiesAvailble.either; do { Console.WriteLine("What is the arrival date?"); while (!DateTime.TryParse(Console.ReadLine(), out startDate)) { DisplayInvalidOption(); } Console.WriteLine("What is the departure date?"); while (!DateTime.TryParse(Console.ReadLine(), out endDate)) { DisplayInvalidOption(); } if (DateTime.Compare(startDate, endDate) > 0) { Console.WriteLine("Please enter arrival date before departure date"); } } while (DateTime.Compare(startDate, endDate) > 0); Console.WriteLine("How many people are camping?"); while (!int.TryParse(Console.ReadLine(), out numPeople)) { DisplayInvalidOption(); } Console.WriteLine("Do you want wheel chair accessiblity? yes/no/either"); bool loopingAccessiblityOption = true; while (loopingAccessiblityOption) { string inputStr = Console.ReadLine().ToLower(); if (inputStr == "yes") { accessible = CampgroundDAO.AccessibleOptions.yes; loopingAccessiblityOption = false; } else if (inputStr == "no") { accessible = CampgroundDAO.AccessibleOptions.no; loopingAccessiblityOption = false; } else if (inputStr == "either") { accessible = CampgroundDAO.AccessibleOptions.either; loopingAccessiblityOption = false; } else { DisplayInvalidOption(); } } Console.WriteLine("How big is your RV?"); while (!int.TryParse(Console.ReadLine(), out rvLength) && rvLength < 0) { DisplayInvalidOption(); } Console.WriteLine("Do you want utilities? yes/no/either"); bool loopingUtilitiesOption = true; while (loopingUtilitiesOption) { string inputStr = Console.ReadLine().ToLower(); if (inputStr == "yes") { utilities = CampgroundDAO.UtilitiesAvailble.yes; loopingUtilitiesOption = false; } else if (inputStr == "no") { utilities = CampgroundDAO.UtilitiesAvailble.no; loopingUtilitiesOption = false; } else if (inputStr == "either") { utilities = CampgroundDAO.UtilitiesAvailble.either; loopingUtilitiesOption = false; } } List <CampgroundSite> sites = _campgroundDAO.GetSitesByParkIdAndResevationAvailability(park.ParkId, startDate, endDate, numPeople, accessible, rvLength, utilities); Console.WriteLine(); Console.WriteLine("Name | Site Number | Max Occupancy | Handicap Access | RV Length | Utilities | Daily Fee"); Console.WriteLine("----------------------------------------------------------------------------------------"); foreach (CampgroundSite campgroundSite in sites) { Site site = campgroundSite.site; Campground campground = campgroundSite.campground; Console.WriteLine($"{campground.Name} " + $"{site.SiteNumber} " + $"{site.MaxOccupancy} " + $"{site.HandicapAccessibility} " + $"{site.MaxRVLength} " + $"{site.HasUtilities} " + $"{campground.DailyFee * (int)(endDate - startDate).TotalDays}"); } bool looping = true; int input = -1; int siteIdTemp = -1; while (looping) { Console.WriteLine("Which Campground should be reserved (enter 0 to cancel)?"); string inputStrCampgroundName = Console.ReadLine(); if (inputStrCampgroundName == "0") { looping = false; } else { Console.WriteLine("What site number whould you like? "); string inputSiteNumer = Console.ReadLine(); if (int.TryParse(inputSiteNumer, out input)) { bool isSiteVaild = false; foreach (CampgroundSite campgroundSite in sites) { if (campgroundSite.campground.Name == inputStrCampgroundName && campgroundSite.site.SiteNumber == input) { siteIdTemp = campgroundSite.site.SiteId; isSiteVaild = true; } } if (isSiteVaild) { Reservation reservation = new Reservation() { SiteId = siteIdTemp, Name = _userMgr.User.LastName + ", " + _userMgr.User.FirstName, FromDate = startDate, ToDate = endDate, CreationDate = DateTime.Now }; reservation.ReservationId = _campgroundDAO.AddReservation(reservation, _userMgr.User); Console.WriteLine($"The reservation has been made and the confirmation id is {reservation.ReservationId} "); looping = false; } else { DisplayInvalidOption(); } } } } Console.ReadLine(); }
public void ParkMenu() { const int Command_ViewCampgrounds = 1; const int Command_SearchReservation = 2; const int Command_AdvancedMenu = 3; const int Command_ReturnToPrevious = 4; bool isValidInput = false; Console.WriteLine("National Parks\n"); IList <Park> parks = parkDAO.GetAllParks(); foreach (Park park in parks) { Console.WriteLine($" {park.ID} - {park.Name}"); } int choice = 0; while (!isValidInput) { choice = CLIHelper.GetInteger("Please choose a park: "); isValidInput = VerifyIntChoice(choice, parks.Count); if (!isValidInput) { Console.WriteLine("That's not a valid choice, please try again..."); } } Park chosenPark = parks.Where(park => park.ID == choice).FirstOrDefault(); Console.Clear(); while (true) { Console.WriteLine(chosenPark); PrintParkMenu(); isValidInput = false; int userInput = 0; while (!isValidInput) { userInput = CLIHelper.GetInteger("Please enter a command: "); isValidInput = VerifyIntChoice(userInput, 4); if (!isValidInput) { Console.WriteLine("That's not a valid command, please try again..."); } } switch (userInput) { case Command_ViewCampgrounds: Console.Clear(); ViewCampgrounds(chosenPark); break; case Command_SearchReservation: Console.Clear(); SearchAvailableSitesForReservations(chosenPark); break; case Command_AdvancedMenu: Console.Clear(); AdvancedMenu(chosenPark); break; case Command_ReturnToPrevious: Console.Clear(); return; default: Console.WriteLine("That's not a valid choice..."); break; } } }
public void SearchForAvailableReservationScreen(Park park) { SiteSqlDal siteSqlDal = new SiteSqlDal(DatabaseConnection); CampgroundSqlDal campgroundSqlDal = new CampgroundSqlDal(DatabaseConnection); ReservationSqlDal reservationSqlDal = new ReservationSqlDal(DatabaseConnection); List <Campground> campgrounds = campgroundSqlDal.GetAllCampgroundsFromPark(park.Id); //Search for valid campground bool done = false; while (!done) { Console.Clear(); Console.WriteLine("Search for Campground Reservation: "); PrintAllCampgroundInfoInPark(park); int userInputCampgroundId = CLIHelper.GetInteger("\nWhich Campground number (Enter 0 to cancel)?"); if (userInputCampgroundId == 0) { Console.WriteLine("Cancelled! Press any key to continue."); Console.ReadKey(); return; } if (GetCampgroundById(userInputCampgroundId, campgrounds) == null) { Console.WriteLine("Not a valid campground! Press any key to continue."); Console.ReadKey(); return; } //Once valid campground has been chosen --> Get good dates for query DateTime checkIn = CLIHelper.GetDateTime("Check-in date: "); DateTime checkOut = CLIHelper.GetDateTime("Check-out date: "); List <Site> availableSitesFromCampgrounds = new List <Site>(); bool gotDates = false; bool showReservationPrompt = false; while (!gotDates) { availableSitesFromCampgrounds = siteSqlDal.GetAvailableSitesFromCampground(userInputCampgroundId, checkIn, checkOut); if (checkOut.CompareTo(checkIn) <= 0) { Console.WriteLine("Cannot check-out earlier or same day as check-in. Press any key to continue"); Console.ReadKey(); showReservationPrompt = false; gotDates = true; //could allow user a choice to return or enter new dates } else if (availableSitesFromCampgrounds.Count < 1) { string dateReset = CLIHelper.GetString("\nThere are no available sites. \nWould you like to enter an alternate date range?\n\tYes or No?").ToLower(); if (dateReset == "yes" || dateReset == "y") { Console.WriteLine(); checkIn = CLIHelper.GetDateTime("Check-in date: "); checkOut = CLIHelper.GetDateTime("Check-out date: "); gotDates = false; } else if (dateReset == "no" || dateReset == "n") { gotDates = true; } else { Console.WriteLine("Invalid input. Try again"); gotDates = false; } } else { showReservationPrompt = true; gotDates = true; } } if (showReservationPrompt) { int daysReserved = checkOut.Subtract(checkIn).Days; Console.WriteLine("Site Id".PadRight(10) + "Max Occup.".PadRight(15) + "Accessible?".PadRight(15) + "Max RV Length".PadRight(20) + "Utility".PadRight(15) + "Cost\n"); foreach (Site site in availableSitesFromCampgrounds) { Console.WriteLine(site.GetPrintString(daysReserved, GetCampgroundById(userInputCampgroundId, campgrounds).DailyFee)); } Console.WriteLine(); MakeReservationPrompts(checkIn, checkOut, availableSitesFromCampgrounds); done = true; } } }
public bool ParkCampgrounds(Park p) { int pad = 20; Console.Clear(); Console.WriteLine(); Console.WriteLine(" " + p.Name.ToUpper() + " PARK CAMPGROUNDS"); Console.WriteLine(); Console.WriteLine(" *".PadRight(95, '*')); Console.WriteLine(" ".PadRight(8) + "Name".PadRight(35) + "Open".PadRight(pad) + "Close".PadRight(pad) + "Daily Fee"); Console.WriteLine(" *".PadRight(95, '*')); CampgroundDAL campgroundDAL = new CampgroundDAL(connectionString); List <Campground> campgrounds = campgroundDAL.GetCampgrounds(p.Id); foreach (Campground cg in campgrounds) { Console.WriteLine(" |#" + cg.AlphaID.ToString() + "|".PadRight(4) + cg.Name.PadRight(35) + GetMonthString(cg.OpenFrom).PadRight(pad) + GetMonthString(cg.OpenTo).PadRight(pad) + "$" + cg.DailyFee.ToString("F2")); } ////BONUS //Console.WriteLine(" |#" + (campgrounds.Count + 1) + "|".PadRight(4) + $"***Choose this option to search across all campgrounds within {p.Name}***"); int alphaID = 0; Console.WriteLine(); Console.WriteLine(" Which campground (enter 0 to cancel)?"); try { alphaID = Convert.ToInt32(Console.ReadLine()); } catch (Exception e) { Console.WriteLine(" Please enter valid option. Press any key to return."); Console.ReadKey(); return(true); } bool campgroundIsInPark = false; foreach (Campground cg in campgrounds) { if (alphaID == cg.AlphaID) { campgroundIsInPark = true; } } if (alphaID == 0) { return(false); } else if (campgroundIsInPark == true) { int cgID = 0; decimal dailyFee = 0; foreach (Campground cg in campgrounds) { if (cg.AlphaID == alphaID) { cgID = cg.Id; dailyFee = cg.DailyFee; } } bool running = true; while (running) { DateTime arriveDate; DateTime departDate; Console.WriteLine(" What is the arrival date? mm/dd/yyyy"); try { arriveDate = Convert.ToDateTime(Console.ReadLine()); } catch (Exception e) { Console.WriteLine("Please enter a valid option. Press any key to return."); Console.ReadKey(); return(true); } Console.WriteLine(" What is the departure date? mm/dd/yyyy"); try { departDate = Convert.ToDateTime(Console.ReadLine()); } catch (Exception e) { Console.WriteLine(" Please enter a valid option. Press any key to return."); Console.ReadKey(); return(true); } if (departDate > arriveDate && (departDate - arriveDate).TotalDays > 0 && arriveDate > DateTime.Today) { running = AvailableForReservation(dailyFee, cgID, arriveDate, departDate); } else { Console.WriteLine(" Please enter a valid option. Press any key to continue."); running = false; } } Console.ReadKey(); return(true); } ////BONUS Optional Selection To Choose All Campgrounds Within Park: //else if (alphaID == (campgrounds.Count + 1)) //{ // int parkID = p.Id; // bool running = true; // while (running) // { // DateTime arriveDate; // DateTime departDate; // Console.WriteLine(" What is the arrival date? mm/dd/yyyy"); // try // { // arriveDate = Convert.ToDateTime(Console.ReadLine()); // } // catch (Exception e) // { // Console.WriteLine("Please enter a valid option. Press any key to return."); // Console.ReadKey(); // return true; // } // Console.WriteLine(" What is the departure date? mm/dd/yyyy"); // try // { // departDate = Convert.ToDateTime(Console.ReadLine()); // } // catch (Exception e) // { // Console.WriteLine(" Please enter a valid option. Press any key to return."); // Console.ReadKey(); // return true; // } // if (departDate > arriveDate && (departDate - arriveDate).TotalDays > 0 && arriveDate > DateTime.Today) // { // running = ParkAvailableForReservation(parkID, arriveDate, departDate); // } // else // { // Console.WriteLine(" Please enter a valid option. Press any key to continue."); // running = false; // } // } // Console.ReadKey(); // return true; //} else { Console.WriteLine(" Please enter a valid option. Press any key to continue."); Console.ReadKey(); return(true); } Console.WriteLine(" Press any key to return to the previous menu"); Console.ReadKey(); return(false); }
/// <summary> /// Preforms a search for campsites available to be reserved /// </summary> /// <param name="currentPark">The park to find a reservation in.</param> /// <param name="fromWholePark">Option to search through all campgrounds in the specified Park.</param> private void SearchForReservation(Park currentPark, bool fromWholePark) { Console.Clear(); //Initialize working variables List <Campground> campgrounds = campDAL.GetCampgrounds(currentPark); List <Site> sites = new List <Site>(); DateTime startDate = DateTime.MinValue; DateTime endDate = DateTime.MinValue; int input = -1; bool continueSearching = true; do { //If the reservation is for a specific campground if (!fromWholePark) { campgrounds = campDAL.GetCampgrounds(currentPark); Console.WriteLine($"Campgrounds in {currentPark.Name}"); PrintCampgroundList(currentPark); //Print list of campgrounds in park to screen //Ask for user choice Console.Write("Which Campground (enter 0 to cancel)? "); input = CLIHelper.GetAnInteger(0, campgrounds.Count); //If User chose a campground, make the list only contain their choice if (input != 0) { campgrounds = new List <Campground>() { campgrounds[input - 1] }; } } //initialize advanced search criteria if (input != 0) { int occupants = 1; bool isAccessible = false; int RVLength = 0; bool hasUtilities = false; //Get reservation dates in correct format Console.Write(">Enter a Start Date for Reservation: "); startDate = CLIHelper.GetDateTime(DateTime.Now.Date); Console.Write(">Enter a Departure Date for Reservation: "); endDate = CLIHelper.GetDateTime(startDate); //Ask user for optional advanced search Console.Write("Would You Like to Preform an Advanced Search? (Y/N): "); bool isAdvancedSearch = CLIHelper.GetBoolean(); //Get user specified advanced search criteria if (isAdvancedSearch) { Console.WriteLine(); Console.Write("How many occupants: "); occupants = CLIHelper.GetAnInteger(1, 55); Console.Write("Do you need Wheelchair Accessiblity? (Y/N): "); isAccessible = CLIHelper.GetBoolean(); Console.Write("How long is your RV? (Enter 0 if not applicable): "); RVLength = CLIHelper.GetAnInteger(0, 35); Console.Write("Utilities Required? (Y/N): "); hasUtilities = CLIHelper.GetBoolean(); } //Print a list of sites that match the search criteria sites = PrintSiteList(startDate, endDate, campgrounds, occupants, isAccessible, RVLength, hasUtilities); //if there are no sites ask to try again or quit if (sites.Count == 0) { Console.Clear(); Console.WriteLine("No Available Sites per Your Specifications."); Console.Write("Would You Like to Try Again? (Y/N): "); continueSearching = CLIHelper.GetBoolean(); Console.WriteLine(); } } //Loop while the search return empty and user has not chosen to continue/quit } while (sites.Count == 0 && input != 0 && continueSearching); //Book a reservation if sites were found if (sites.Count != 0) { BookAReservation(sites, startDate, endDate); } }
public bool ParkInfoScreen(Park p) { Console.Clear(); Console.WriteLine(" *".PadRight(30, '*')); Console.WriteLine(" " + p.Name + " National Park"); Console.WriteLine(" *".PadRight(30, '*')); Console.WriteLine(" Location:".PadRight(20) + p.Location); Console.WriteLine(" Established:".PadRight(20) + p.EstDate.ToShortDateString()); Console.WriteLine(" Area:".PadRight(20) + String.Format("{0:n0}", p.Area) + " sq km"); Console.WriteLine(" Annual Visitors:".PadRight(20) + String.Format("{0:n0}", p.NumVisitors)); Console.WriteLine(); Console.WriteLine(" " + p.Description); Console.WriteLine(); Console.WriteLine(" *".PadRight(25, '*')); Console.WriteLine(" Please Select An Option:"); Console.WriteLine(" *".PadRight(25, '*')); Console.WriteLine(" |1| View Campgrounds"); Console.WriteLine(" |2| Search for Reservation"); Console.WriteLine(" |3| See Upcoming Reservations (30 Days Out)"); Console.WriteLine(" |4| Return to Previous Screen"); string input = Console.ReadLine(); if (input == "1") { bool running = true; while (running) { running = PrintCampgrounds(p); } return(true); } else if (input == "2") { bool running = true; while (running) { running = ParkCampgrounds(p); } return(true); } //BONUS else if (input == "3") { Console.Clear(); ReservationSiteDAL allReservations = new ReservationSiteDAL(connectionString); bool running = true; while (running) { DateTime arriveDate = DateTime.Today; int pad = 15; Console.WriteLine(); Console.WriteLine(" UPCOMING RESERVATIONS 30 DAYS OUT"); Console.WriteLine(); Console.WriteLine(" *".PadRight(110, '*')); Console.WriteLine(" Res.#".PadRight(9) + "Reserved For".PadRight(35) + "Site#".PadRight(8) + "Campground".PadRight(17) + "Daily Fee".PadRight(10) + "From Date".PadRight(pad) + "To Date"); Console.WriteLine(" *".PadRight(110, '*')); List <ReservationSite> listOfAvailableSites = allReservations.GetAllReservations(p.Id, arriveDate); foreach (ReservationSite r in listOfAvailableSites) { Console.WriteLine(" " + r.ReservationID.ToString().PadRight(9) + r.ReservationName.ToString().PadRight(35) + r.SiteNumber.ToString().PadRight(8) + r.CampgroundName.PadRight(16) + "$" + r.DailyFee.ToString("F2").PadRight(10) + /*r.MaxOccupancy.ToString().PadRight(padding) + r.Accessible.PadRight(padding) + r.MaxRvLength.ToString().PadRight(padding) + r.Utilities.PadRight(padding) +*/ r.FromDate.ToShortDateString().PadRight(pad) + r.ToDate.ToShortDateString()); } if (listOfAvailableSites.Count == 0) { Console.WriteLine("There are no reservations for the next 30 days."); } Console.WriteLine(); Console.WriteLine("Press any key to return to the previous screen."); Console.ReadKey(); return(true); } } else if (input == "4") { return(false); } else { Console.WriteLine(" Please enter a valid option. Press any key to continue."); Console.ReadKey(); return(true); } return(true); }