}//ViewCampgroundsList private List <Site> CampgroundReservationSearchResults(int park_Id, int campground_id, DateTime from_date, DateTime to_date) { // Connect to Database. Return onlty the first 5 available campsites per requirements; CampgroundDAL campgroundDal = new CampgroundDAL(DatabaseConnection); SiteDAL siteDAL = new SiteDAL(DatabaseConnection); List <Site> sites = siteDAL.GetAvailableSitesforCampground(campground_id, from_date, to_date); if (sites != null) { //Dispaly Site#, Max Occupancy, Accessibility, Max RV Length, and whether Utilities are available Console.WriteLine($"{"Site No.".PadRight(10)}{"Max Occup.".PadRight(15)}{"Accessible?".PadRight(15)}{"Max Rv Length".PadRight(15)}{"Utility".PadRight(15)}{"Stay Cost".PadRight(10)}"); foreach (Site site in sites) { TimeSpan daysBooking = (to_date.Date - from_date.Date); int days = (int)daysBooking.TotalDays; string cost = ((campgroundDal.GetCost(campground_id) * days)).ToString("C").PadRight(10); string siteWithCost = (site.ToString() + cost); Console.WriteLine(siteWithCost); } } else { NoSitesAvailable(); } return(sites); }//CampgroundReservationSearchResults
static void Main(string[] args) { // Get the connection string from the appsettings.json file IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("Project"); /******************************************************************** * // If you do not want to use CLIMenu, you can remove the following *********************************************************************/ // Create any DAOs needed here, and then pass them into main menu... ParkDAL parkDal = new ParkDAL(connectionString); CampgroundDAL campDal = new CampgroundDAL(connectionString); SiteDAL siteDal = new SiteDAL(connectionString); ReservationDAL reservationDAL = new ReservationDAL(connectionString); MainMenu mainMenu = new MainMenu(parkDal, campDal, siteDal, reservationDAL); // You'll probably be adding daos to the constructor //Run the menu. mainMenu.Run(); }
public void GetCampgroundsTest() { CampgroundDAL campgroundDAL = new CampgroundDAL(connectionString); List <Campground> campgrounds = campgroundDAL.GetCampground(1); Assert.AreEqual(numberOfCampgroundsPark1 + 1, campgrounds.Count); }
private void DisplayParkOptions() { //menu to show options within the park selected above Console.WriteLine("Select a Command:"); Console.WriteLine("1) View Campgrounds" + Environment.NewLine + "2) Search for Reservation" + Environment.NewLine + "3) Return to Previous Screen" + Environment.NewLine + "4) View Upcoming Reservations"); CampgroundDAL camp = new CampgroundDAL(DatabaseConnection); while (true) { string choice = Console.ReadLine(); switch (choice) { case "1": GetCampGrounds(); break; case "2": SearchForSite(); break; case "3": DisplayParks(); break; case "4": AllReservations30Days(); break; default: Console.WriteLine("Please enter a valid command."); break; } } }
private void GetAllCampgrounds() { ParksDAL pdal = new ParksDAL(DatabaseConnection); List <Park> parks = pdal.GetAllParks(); if (parks.Count > 0) { foreach (Park park in parks) { Console.WriteLine("(" + park.Park_id + ") " + park.Name); Console.WriteLine(); } CampgroundDAL cdal = new CampgroundDAL(DatabaseConnection); int parkId = CLIHelper.GetInteger("Please select a Park Id : "); Console.WriteLine(); List <Campground> campground = cdal.GetAllCampgrounds(parkId); foreach (Campground camp in campground) { Console.WriteLine("(" + camp.CampgroundId + ") " + camp.Name.PadRight(30) + "Opening Month " + months[camp.OpenFromMM].ToString().PadRight(10) + "Closing Month " + months[camp.OpenToMM].ToString().PadRight(10) + "Daily Fee " + camp.DailyFee.ToString("c")); Console.WriteLine(); } } else { Console.WriteLine("**** NO RESULTS ****"); } Console.ReadLine(); }
//Methods /// <summary> /// Override of ToString method. /// </summary> /// <returns>Properly formatted site information</returns> /// Method pulls database information for campground name and campground cost. public string ToString(int numDays) { string connectionString = ConfigurationManager.ConnectionStrings["CapstoneDatabase"].ConnectionString; CampgroundDAL cgDAL = new CampgroundDAL(connectionString); Campground cg = cgDAL.GetCampgroundByID(this.CampgroundID); string result; result = cg.Name.PadRight(35); result += this.SiteNumber.ToString().PadRight(10); result += this.MaxOccupancy.ToString().PadRight(12); result += this.Accessible ? "YES".PadRight(15) : "NO".PadRight(15); if (this.MaxRVLength > 0) { result += this.MaxRVLength.ToString().PadRight(10); } else { result += "N/A".PadRight(10); } result += this.Utilities ? "YES".PadRight(11) : "N/A".PadRight(11); result += cg.CalculateFee(numDays); return(result); }
public void GetCostTest() { CampgroundDAL dal = new CampgroundDAL(connectionString); decimal cost = dal.GetCost(campgroundId); Assert.AreEqual(1.00M, dal.GetCost(campgroundId)); }
public void GetCampgroundByIDTest() { CampgroundDAL sqlDAL = new CampgroundDAL(connectionString); Campground campground = sqlDAL.GetCampgroundByID(campgroundID); Assert.IsNotNull(campground); Assert.AreEqual("ABC Camp", campground.Name); }
public void GetCampgroundsTest() { CampgroundDAL sqlDAL = new CampgroundDAL(connectionString); List <Campground> campgrounds = sqlDAL.GetCampgrounds(parkID); Assert.IsNotNull(campgrounds); Assert.AreEqual(1, campgrounds.Count); }
public void GetCampgroundTest() { CampgroundDAL dal = new CampgroundDAL(connectionString); List <Campground> campgrounds = dal.GetCampground(1); Assert.AreEqual(1, campgrounds.Count); Assert.AreEqual("dummycampground", campgrounds[0].Name); }
public void GetListOfCampgounds() { CampgroundDAL dal = new CampgroundDAL(connectionString); List <Campground> c = dal.GetCampGroundsList(1); bool output = c.Count > 0; Assert.IsTrue(output); }
public void GetCampgroundsTest() { CampgroundDAL campgroundDAL = new CampgroundDAL(connectionString); List <Campground> campgrounds = campgroundDAL.GetCampgrounds(parkID); Assert.AreEqual(1, campgrounds.Count); Assert.AreEqual("Fish Creek", campgrounds[0].Name); }
public void TestAvailableCampgroundsFail() { CampgroundDAL campgroundDAL = new CampgroundDAL(connectionString); campgroundDAL.GetCampground(1); bool result = campgroundDAL.CampgroundCheck(testId, 1, "2018-05-10", "2018-06-14"); Assert.AreEqual(false, result); }
public void ViewCampgroundsTest() { CampgroundDAL campgroundDAL = new CampgroundDAL(connectionString); Park newPark = new Park(); List <Campground> campground = campgroundDAL.ViewCampgrounds(newPark); Assert.AreEqual(0, campground.Count); }
public void DatesPrompt(int campgroundId, Park selectedPark) { string fromDate; string toDate; bool isDone = false; CampsiteDAL campsiteDAL = new CampsiteDAL(connectionString); CampgroundDAL campgroundDAL = new CampgroundDAL(connectionString); List <Campsite> campsites; try { do { Console.WriteLine("\nWhat is the arrival date? (yyyy-mm-dd)"); fromDate = Console.ReadLine(); Console.WriteLine("\nWhat is the departure date? (yyyy-mm-dd)"); toDate = Console.ReadLine(); if (!AreDatesInFuture(fromDate, toDate) || !ArriveBeforeDepartCheck(fromDate, toDate)) { Console.WriteLine(""); Console.WriteLine("Sorry, those are not valid dates."); } else if (!campgroundDAL.CampgroundCheck(campgroundId, selectedPark.Id, fromDate, toDate)) { Console.WriteLine(""); Console.WriteLine("Sorry, the campground is not open during those dates."); } else { isDone = true; } }while (!isDone); campsites = campsiteDAL.GetCampsites(campgroundId, fromDate, toDate); if (campsites.Count == 0) { NoCampsitesAvailablePrompt(campsites); } else { DisplayAvailableReservations(campsites, toDate, fromDate); DisplayCreateReservationMenu(campsites, fromDate, toDate); } } catch (Exception ex) { Console.WriteLine(); Console.WriteLine("Not a valid value- please try again"); } }
private void SearchForAvailableReservations(int ParkID) { string CampgroundChoice = CLIHelper.GetString("Which campground would you like?"); string ArrivalDate = CLIHelper.GetDate("What is the arrival date?"); string DepartureDate = CLIHelper.GetDate("What is the departure date?"); SiteDAL sdal = new SiteDAL(DatabaseConnection); List <Site> slist = sdal.ViewAvailReservations(CampgroundChoice, ArrivalDate, DepartureDate); if (slist.Count > 0) { CampgroundDAL cgdal = new CampgroundDAL(DatabaseConnection); double camgroundCost = cgdal.GetCampgroundCost(CampgroundChoice); Console.WriteLine("Available sites & details for your dates:"); Console.WriteLine("Site ID" + " " + "Max Occupancy" + " " + "Accessible?" + " " + "Max RV Length" + " " + "Utilities" + " " + "Cost"); foreach (Site item in slist) { Console.Write(" " + item.site_id.ToString().PadRight(9) + " " + item.max_occupancy.ToString().PadRight(10) + " " + TrueFalse(item.accessible).ToString().PadRight(14) + " " + item.max_rv_length.ToString().PadRight(10) + " " + TrueFalse(item.utilities).ToString().PadRight(8) + " " + camgroundCost); Console.WriteLine(); } string siteChoiceToReserve = CLIHelper.GetString("Which site should be reserved (enter 0 to cancel)"); if (siteChoiceToReserve == "0") { return; } bool SiteIsInTheList = false; foreach (Site item in slist) { if (item.site_id.ToString() == siteChoiceToReserve) { SiteIsInTheList = true; } } if (!SiteIsInTheList) { Console.WriteLine("Sorry, that Site ID isn't in our list! Please start over."); return; } string name = CLIHelper.GetString("What name should the reservation be made under?"); MakeReservation(siteChoiceToReserve, name, ArrivalDate, DepartureDate); } else { Console.WriteLine("Sorry, no campsites are available. Please try again with different dates."); return; } }
public void GetAllCampgroundsForPark() { //Arrange CampgroundDAL campgroundDAL = new CampgroundDAL(_connectionString); //Act List <Campground> campgrounds = campgroundDAL.GetAllCampgroundsForPark(park); //Assert Assert.AreEqual(1, campgrounds.Count); Assert.AreEqual(_campgroundId, campgrounds[0].CampgroundId); }
public void GetAllCampgroundsPerPark_Test() { //Arrange CampgroundDAL dal = new CampgroundDAL(ConnectionString); int parkId = 1; //Act var campgrounds = dal.GetAllCampgroundsPerPark(parkId); //Assert Assert.AreEqual(1, campgrounds.Count); }
public void GetAllCampgroundsForAParkTest() { //Arrange CampgroundDAL dal = new CampgroundDAL(connectionString); //Act List <Campground> campgrounds = dal.GetAllCampgroundsForAPark(parkId); //Assert Assert.IsNotNull(campgrounds); Assert.AreEqual(1, campgrounds.Count); }
private void GetCampgroundNow(int parkID) { int count = 0; CampgroundDAL dal = new CampgroundDAL(databaseConnection); List <Campground> currentCampList = dal.GetCampground(parkID); Console.WriteLine(" Name | Open | Close | Daily Fee"); currentCampList.ForEach(currentCamp => { count = count + 1; Console.WriteLine($"{currentCamp.Id}) {currentCamp.Name} | {dal.NumberToMonth(currentCamp.DateOpen)} | {dal.NumberToMonth(currentCamp.DateClosed)} | {currentCamp.DailyFee.ToString("c")}"); }); }
public void NoCampgroundsAtParkTest() { // Arrange CampgroundDAL cDAL = new CampgroundDAL(connectionString); //Act IList <CampGround> cGround = cDAL.DisplayCampGrounds(2); //Assert int grounds = cGround.Count; Assert.AreEqual(0, grounds); }
private void SeeUpcomingReservationsForParkCLI(Park park) { //Title Display Console.WriteLine("UNDER CONSTRUCTION: Upcoming Reservation feature coming soon!"); Console.Clear(); string snName = "Upcoming Park Reservations Menu"; Console.SetCursorPosition((Console.WindowWidth - snName.Length) / 2, Console.CursorTop); Console.WriteLine(snName); string snNameDash = "--------------------------------------"; Console.SetCursorPosition((Console.WindowWidth - snNameDash.Length) / 2, Console.CursorTop); Console.WriteLine(snNameDash); Console.WriteLine(); //Set up DALs and get list of Reservations ReservationDAL reservationDAL = new ReservationDAL(DatabaseConnection); List <Reservation> upcomingReservations = reservationDAL.GetReservationsForNext30DaysInPark(park); CampgroundDAL campgroundDAL = new CampgroundDAL(DatabaseConnection); List <Campground> allCampgroundsForPark = campgroundDAL.GetAllCampgroundsForPark(park); SiteDAL siteDAL = new SiteDAL(DatabaseConnection); List <Site> allSites = new List <Site>(); //Display Reservations if (upcomingReservations.Count() == 0) { Console.WriteLine($"There are no reservations at {park.Name} National Park in the next 30 days."); } else { Console.WriteLine($"Reservations at {park.Name} National Park beginning within the next 30 days:"); Console.WriteLine(); int upcomingReservationDisplayCounter = 0; foreach (Reservation item in upcomingReservations) { if (upcomingReservationDisplayCounter == 0) { Console.WriteLine("{0,-35}{1,-20}{2,-10}{3,-15}{4,-10}", "RESERVATION NAME", "CAMPGROUND", "SITE", "START DATE", "END DATE"); } Console.WriteLine("{0,-35}{1,-20}{2,-10}{3,-15}{4,-10}", item.Name, item.CampgroundName, item.SiteId.ToString(), item.FromDate.ToShortDateString(), item.ToDate.ToShortDateString()); upcomingReservationDisplayCounter++; } } Console.WriteLine(); Console.WriteLine("Press any key to return to Park Menu"); Console.ReadKey(); }
public void GetCampgrounds(int parkId, int expectedOutput) { // Arrange CampgroundDAL campground = new CampgroundDAL(ConnectionString); // Act var listOfCampgrounds = campground.GetCampgrounds(new Park() { ParkId = parkId }); // Assert Assert.AreEqual(expectedOutput, listOfCampgrounds.Count); }
public void DisplayCampgroundInformation(Park selectedPark) { CampgroundDAL campgroundDAL = new CampgroundDAL(connectionString); List <Campground> campgrounds = campgroundDAL.GetCampground(selectedPark.Id); Console.WriteLine($"\n{selectedPark.Name} National Park Grounds"); Console.WriteLine("ID Name Open Mo Close Mo Daily Fee"); Console.WriteLine("-------------------------------------------------------------------"); foreach (Campground campground in campgrounds) { Console.WriteLine(campground.ToString()); } return; }
public void GetAllCampgroundsTest() { Campground camp = new Campground(); camp.Name = "fake ground"; camp.OpenFromMM = 01; camp.OpenToMM = 01; camp.DailyFee = 5; camp.ParkId = 1; CampgroundDAL dal = new CampgroundDAL(connectionsrting); List <Campground> output = dal.GetAllCampgrounds(1); Assert.IsTrue(output.Count > 0); }
/// <summary> /// method that calls campground DAL to return a list of campgrounds at selected Park /// </summary> /// <param name="parkId"></param> public bool DisplayCampgrounds(int parkId) { bool reservationMade = false; while (true) { //instantiate a campground DAL and use its method for getting //a dictionary of all campgrounds at specified park CampgroundDAL dal = new CampgroundDAL(DatabaseConnection); Console.Clear(); IDictionary <int, Campground> campground = dal.GetAllCampgroundsPerPark(parkId); //iterate through dictionary of campgrounds and display properties of each Console.WriteLine(" ".PadRight(5) + "Name".PadRight(35) + "Open".PadRight(10) + "Close".PadRight(13) + "Daily Fee".PadRight(10)); foreach (KeyValuePair <int, Campground> camps in campground) { Console.WriteLine("#" + camps.Key.ToString().PadRight(4) + camps.Value.Name.ToString().PadRight(35) + camps.Value.OpenFrom.ToString().PadRight(10) + camps.Value.OpenTo.ToString().PadRight(13) + camps.Value.DailyFee.ToString("c").ToString().PadRight(10)); } Console.WriteLine(); Console.WriteLine("Select A Command"); Console.WriteLine("1) Search for available reservation"); Console.WriteLine("2) Return to previous screen"); string campgroundChoice = Console.ReadLine(); Console.Clear(); if (campgroundChoice == "1") { SiteSearchCLI siteSearch = new SiteSearchCLI(); reservationMade = siteSearch.PromptUserForDateRange(parkId); break; } else if (campgroundChoice == "2") { break; } else { Console.WriteLine("Please enter a valid selection"); } } return(reservationMade); }
public List <Campground> PrintAllCampgrounds(int parkId) { Console.Clear(); CampgroundDAL dal = new CampgroundDAL(); List <Campground> campgrounds = dal.GetAllCampgrounds(parkId); int counter = 1; Console.WriteLine("ID".PadRight(6) + "Name".PadRight(35) + "Open".PadRight(15) + "Close".PadRight(15) + "Daily Fee".PadRight(15)); foreach (Campground campground in campgrounds) { Console.WriteLine("#" + campground.CampgroundId.ToString().PadRight(5) + campground.Name.PadRight(35) + DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName(campground.OpeningMonth).ToString().PadRight(15) + DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName(campground.ClosingMonth).ToString().PadRight(15) + campground.DailyFee.ToString("C").PadRight(15)); counter++; } Console.WriteLine(); return(campgrounds); }
public void ViewCampgrounds(int parkID) { CampgroundDAL campground = new CampgroundDAL(connectionString); List <Campground> campgrounds = campground.GetCampgrounds(parkID); Console.Clear(); Console.WriteLine(" Name".PadRight(43) + "Open".PadRight(12) + "Close".PadRight(12) + "Daily Fee"); int index = 1; foreach (Campground camp in campgrounds) { Console.Write(index + ") "); Console.WriteLine(camp); index++; } bool invalidSelection = false; do { Console.WriteLine(); Console.WriteLine("Select a command"); Console.WriteLine("1) Search for Available Reservation"); Console.WriteLine("2) Return to Park Information Screen"); string input = CLIHelper.GetString("Please enter a selection: "); switch (input) { case "1": int campInput = CLIHelper.GetInteger("Which campground do you wish to make a reservation for: "); MakeReservation(parkID, campgrounds[campInput - 1].CampgroundID); return; case "2": ViewParkInfo(parkID); break; default: Console.WriteLine("Please make a valid selection: "); invalidSelection = true; break; } } while (invalidSelection); }
public void GetThisParksCampgrounds(string parkName) //and write them to the screen { List <Campground> campgroundList = new List <Campground>(); Console.Clear(); Console.WriteLine("Park Campgrounds"); Console.WriteLine(allParks[parkIndex].Name + " National Park Campgrounds\n"); Console.WriteLine("".PadRight(5) + "Name".PadRight(35) + "Open".PadRight(12) + "Close".PadRight(12) + "Daily Fee"); CampgroundDAL campDAL = new CampgroundDAL(connectionString); campgroundList = campDAL.GetThisParksCampgrounds(parkName); for (int i = 0; i < campgroundList.Count; i++) { Console.WriteLine("#" + (i + 1) + ")".PadRight(5) + campgroundList[i].Name.PadRight(35) + DateAndTime.MonthName(campgroundList[i].OpenFrom).PadRight(12) + DateAndTime.MonthName(campgroundList[i].OpenTo).PadRight(12) + (campgroundList[i].DailyFee / 100).ToString("C2")); } }
public void ReturnsCampgroundsCorrectly() { // Arrange CampgroundDAL testClass = new CampgroundDAL(); // Act int expectedParkCount1 = GetCampgroundCount(1); List <Campground> campgrounds1 = testClass.GetAllCampgrounds(1); int expectedParkCount2 = GetCampgroundCount(2); List <Campground> campgrounds2 = testClass.GetAllCampgrounds(2); int expectedParkCount3 = GetCampgroundCount(3); List <Campground> campgrounds3 = testClass.GetAllCampgrounds(3); // Assert Assert.AreEqual(expectedParkCount1, campgrounds1.Count); Assert.AreEqual(expectedParkCount2, campgrounds2.Count); Assert.AreEqual(expectedParkCount3, expectedParkCount3); }