public void DisplayCampsByParkId(int parkId, Dictionary <int, Park> listOfParks) { if (listOfParks.ContainsKey(parkId)) { CampgroundSqlDal dal = new CampgroundSqlDal(dbConnection); Dictionary <int, Campground> listOfCamps = dal.GetAllCampsByParkId(parkId); Console.WriteLine("Camp Id\t\t Name\t\t\t\t Open From\t Open Until\t Daily Fee"); if (listOfCamps.Count > 0) { foreach (int key in listOfCamps.Keys) { Console.WriteLine(listOfCamps[key].ToString()); } Console.WriteLine("Please select campground to search for available dates or press 0 to return ___"); int campId = Convert.ToInt32(Console.ReadLine()); if (campId == 0) { return; } if (listOfCamps.ContainsKey(campId)) { SearchByCampId(campId); } else { Console.WriteLine("Invalid Campground ID: "); } } } else { Console.WriteLine("Invalid Park ID - Please choose a valid park."); } }
public void SearchByCampId(int campId) { CampgroundSqlDal campDal = new CampgroundSqlDal(dbConnection); Dictionary <int, Campground> listOfCamp = campDal.GetNameByCampId(campId); Console.WriteLine(@"What is the arrival date? __/__/____ "); DateTime fromDate = Convert.ToDateTime(Console.ReadLine()); Console.WriteLine(@"What is the departure date? __/__/____ "); DateTime toDate = Convert.ToDateTime(Console.ReadLine()); if (fromDate.Month >= listOfCamp[campId].OpenFromMonth && toDate.Month <= listOfCamp[campId].OpenToMonth) { Console.WriteLine("Results Matching Your Search Criteria\r\n "); Console.WriteLine("Camp Name. \t\t Site No.\t Max Occup.\t Accessible?\t RV Len \t Utility\t Cost"); SearchAvailableSitesByCampId(campId, fromDate, toDate); MakeReservation(fromDate, toDate); } else { Console.WriteLine(@"Invalid Date(s), park is not open on one of these dates. "); } }
public void GetAllCampgroundsFromParkTest() //List<Campground> GetAllCampgroundsFromPark(int parkId) { //Arange CampgroundSqlDal campgroundSqlDal = new CampgroundSqlDal(connectionString); //ACT List <Campground> campgrounds = campgroundSqlDal.GetAllCampgroundsFromPark(1); //Assert Assert.IsNotNull(campgrounds, "Campgrounds list is empty!"); Assert.AreEqual(campgroundCount, campgrounds.Count, $"Expected a count of {campgroundCount} for campgrounds"); //Insert Assert bool found = false; foreach (Campground campground in campgrounds) { if (campground.Name == "Test Campground") { found = true; break; } } Assert.IsTrue(found, "Could not find Test Campground named Test Campground"); }
public void SearchAvailableSitesByCampId(int campId, DateTime fromDate, DateTime toDate) { TimeSpan totalDays = toDate.Subtract(fromDate); int days = Convert.ToInt32(totalDays.Days); SiteSqlDal dal = new SiteSqlDal(dbConnection); List <Site> listOfAvailableSites = dal.GetAllAvailableSitesForCamp(campId, fromDate, toDate); //when working on the bonus search - move this to new method and call it CampgroundSqlDal campDal = new CampgroundSqlDal(dbConnection); Dictionary <int, Campground> listOfCamp = campDal.GetNameByCampId(campId); if (listOfAvailableSites.Count > 0) { for (int i = 0; i < listOfAvailableSites.Count; i++) { Console.Write(listOfCamp[campId].Name + "\t\t"); Console.Write(listOfAvailableSites[i].SiteNumber + "\t\t"); Console.Write(listOfAvailableSites[i].MaxOccupancy + "\t\t"); if (listOfAvailableSites[i].Accessible) { Console.Write("Yes\t\t"); } else { Console.Write("No\t\t"); } if (listOfAvailableSites[i].MaxRVLength == 0) { Console.Write("N/A\t\t"); } else { Console.Write(listOfAvailableSites[i].MaxRVLength + " \t\t"); } if (listOfAvailableSites[i].Utilities) { Console.Write("Yes\t\t"); } else { Console.Write("N/A\t\t"); } Console.Write(listOfCamp[campId].DailyFee * days); Console.WriteLine(); } } else { Console.WriteLine("Sorry there are no available sites for your requested dates."); } }
public void PrintAllCampgroundInfoInPark(Park park) { Console.WriteLine(park.Name + "\n"); Console.WriteLine("Id".PadRight(5) + "Name".PadRight(35) + "Open".PadRight(20) + "Close".PadRight(20) + "Daily Fee\n"); CampgroundSqlDal campgroundSqlDal = new CampgroundSqlDal(DatabaseConnection); List <Campground> campgrounds = campgroundSqlDal.GetAllCampgroundsFromPark(park.Id); foreach (Campground campground in campgrounds) { Console.WriteLine(campground); } }
public void ProcessCustomerOption() { DisplaySubMenu(); ParkSqlDal dal = new ParkSqlDal(dbConnection); Dictionary <int, Park> listOfParks = dal.GetAllParks(); int parkId; while (true) { string userInput = Console.ReadLine(); if (userInput == "1") // park details { DisplayAllParks(listOfParks); Console.WriteLine("Please Choose A Park To View Details"); parkId = Convert.ToInt32(Console.ReadLine()); DisplayParkDetails(parkId, listOfParks); } else if (userInput == "2") { DisplayAllParks(listOfParks); Console.WriteLine("Please Select A Park ID To View All Campground Sites"); parkId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(@"What is the arrival date? __/__/____ "); DateTime fromDate = Convert.ToDateTime(Console.ReadLine()); Console.WriteLine(@"What is the departure date? __/__/____ "); DateTime toDate = Convert.ToDateTime(Console.ReadLine()); if (listOfParks.ContainsKey(parkId)) { CampgroundSqlDal campDal = new CampgroundSqlDal(dbConnection); Dictionary <int, Campground> listOfCamp = campDal.GetAllCampsByParkId(parkId); Console.WriteLine(); Console.WriteLine("Results Matching Your Search Criteria "); foreach (int key in listOfCamp.Keys) { if (fromDate.Month >= listOfCamp[key].OpenFromMonth && toDate.Month <= listOfCamp[key].OpenToMonth) { Console.WriteLine("Camp Name \t\t Site No.\t Max Occup.\t Accessible?\t RV Len \t Utility\t Cost"); SearchAvailableSitesByCampId(key, fromDate, toDate); //MakeReservation(fromDate, toDate); } else { Console.WriteLine(@"Invalid Date(s), park is not open on one of these dates. "); } } //after printing out all the available sites, calls make reservation method MakeReservation(fromDate, toDate); } } else if (userInput == "3") { //Console.Clear(); DisplayAllParks(listOfParks); Console.WriteLine("Please Select A Park ID To View Campgrounds"); parkId = Convert.ToInt32(Console.ReadLine()); if (listOfParks.ContainsKey(parkId)) { DisplayCampsByParkId(parkId, listOfParks); } else { Console.WriteLine("Invalid Park ID Selection, Please try again. "); } } else if (userInput == "4") { return; } DisplaySubMenu(); } }
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; } } }