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);
            }
        }
示例#2
0
        public bool PickThisParkOrGoBack(string parkName)
        {
            Console.WriteLine("Please select a command");
            Console.WriteLine();
            Console.WriteLine($"  1) View Campgrounds for {parkName}");
            Console.WriteLine("  2) Look for Reservations");
            Console.WriteLine("  3) Return to previous screen");
            int commandSelection = CLIHelper.GetInteger("\nSELECT ONE:  ");

            switch (commandSelection)
            {
            case 1:
                GetThisParksCampgrounds(parkName);
                CaseOneSubMenu(parkName);
                return(true);;

            case 2:
                bool searchingMenuToggle = true;
                while (searchingMenuToggle)
                {
                    searchingMenuToggle = SearchForAvailableReservations(parkName);
                }
                return(true);;      //why does this need a second semicolon?

            case 3:
                return(false);     //returning false exits the method and returns false to the parkMenuToggle which backs up a menu

            default:
                Console.WriteLine("That is not a valid command, try again.");
                return(true);
            }
        }
示例#3
0
        public void CaseOneSubMenu(string parkName)
        {
            Console.WriteLine("\n");
            Console.WriteLine("Select a Command");
            Console.WriteLine("".PadRight(5) + "1) Search For Available Reservations");
            Console.WriteLine("".PadRight(5) + "2) Return to Previous Screen");
            int commandSelection = CLIHelper.GetInteger("\nSELECT ONE:  ");

            switch (commandSelection)
            {
            case 1:
                bool searchingReservations = true;
                while (searchingReservations)
                {
                    searchingReservations = SearchForAvailableReservations(parkName);
                }
                break;

            case 2:
                return;

            default:
                Console.WriteLine("The command provided was not a valid command, please try again.");
                break;
            }
        }
        public void SearchReservationOrPreviousMenu()
        {
            string SearchReservationOrMenu = "\nSelect a Command:\n1) Search Reservation\n2) Previous Menu\n";
            int    commandInput            = CLIHelper.GetInteger(SearchReservationOrMenu, 2, false);

            if (commandInput == 1)
            {
                SearchForCampgroundReservation();
            }
            else if (commandInput == 2)
            {
                ViewCampgroundsOrSearchReservationMenu();
            }
        }
示例#5
0
        public void ReserveSelectedCampsite(List <Site> availableCampsites, string startDate, string endDate)
        {
            int       siteNumber               = 0;
            int       reservationId            = 0;
            int       reservationSuccessToggle = 0;
            const int validCampSite            = 1;

            while (reservationSuccessToggle != validCampSite)
            {
                siteNumber = CLIHelper.GetInteger("\nWhich site would you like to reserve? (or enter 0 to cancel)  ___ ");
                if (siteNumber == 0)
                {
                    return;
                }
                else
                {
                    for (int i = 0; i < availableCampsites.Count; i++)
                    {
                        if (availableCampsites[i].SiteNumber == siteNumber)
                        {
                            Console.WriteLine($"  --Selcted Site Number {availableCampsites[i].SiteNumber} for {startDate} till {endDate}-- \n");
                            reservationSuccessToggle = validCampSite;
                        }
                    }
                    if (reservationSuccessToggle != validCampSite)
                    {
                        Console.WriteLine("That site number is not found.  Please select one of the available camp sites");
                        Console.ReadLine();
                    }
                }

                string reservationName = CLIHelper.GetString("What name would you like to use for the reservation?  ___ ");

                ReservationDAL resDAL = new ReservationDAL(connectionString);
                reservationId = resDAL.CreateNewReservation(reservationName, startDate, endDate, siteNumber);

                Console.WriteLine($"\nThe reservation has been made under the name {reservationName} and the confirmaion id is {reservationId}");
                Console.ReadLine();


                return;
            }
        }
        public void ViewCampgroundsOrSearchReservationMenu()
        {
            string parkInputView = "\nSelect a Command:\n1) View Campgrounds\n2) Search for Reservation\n"
                                   + "3) Return to Previous Screen";
            int commandInput = CLIHelper.GetInteger(parkInputView, 3, false);

            if (commandInput == 1)
            {
                ViewCampground();
            }
            else if (commandInput == 2)
            {
                Console.WriteLine("BONUS section not yet implemented");
            }
            else if (commandInput == 3)
            {
                ViewParksInterface();  //should be a return statement.  This creates recursion.
                //The return statement will take it back to method that called it--in this case ParkInfoScreen.
            }
        }
示例#7
0
        public bool SearchForAvailableReservations(string parkName)
        {
            GetThisParksCampgrounds(parkName);
            CampgroundDAL     campDAL = new CampgroundDAL(connectionString);
            List <Campground> thisParksCampgroundList = campDAL.GetThisParksCampgrounds(parkName);

            int    campgroundIndex = 0;
            string startDate       = "";
            string endDate         = "";

            campgroundIndex = CLIHelper.GetInteger("\nSelect a campground (enter 0 to cancel)  ___ ") - 1;
            if (campgroundIndex == -1)
            {
                return(false);  //returns to previous method (and menu)
            }
            else if (campgroundIndex < 0 || campgroundIndex > thisParksCampgroundList.Count - 1)
            {
                Console.WriteLine("\nSelect a valid campground from the list.");
                Console.ReadLine();
                return(true);
            }

            startDate = CLIHelper.GetString("What day do you plan to arrive?  mm/dd/yyyy ");
            if (!DateTime.TryParse(startDate, out DateTime startResult))
            {
                Console.WriteLine("\nThat is not an acceptable Date format");
                Console.ReadLine();
                return(true);
            }

            endDate = CLIHelper.GetString("What day do you plan to checkout?  mm/dd/yyyy ");
            if (!DateTime.TryParse(endDate, out DateTime endResult))
            {
                Console.WriteLine("\nThat is not an acceptable Date format");
                Console.ReadLine();
            }
            else if (endResult < startResult)
            {
                Console.WriteLine("\nThat departure date is before the Arrival Date. Try again.");
                Console.ReadLine();
                return(true);
            }

            SiteDAL     siteDAL            = new SiteDAL(connectionString);
            List <Site> availableCampsites = siteDAL.GetSitesFreeInCampground(thisParksCampgroundList[campgroundIndex].Name, startDate, endDate);

            Console.Clear();
            Console.Write("\n\nHere are the results matching your search criteria for:");
            Console.WriteLine("\n\nAvailable Camp Sites at " + parkName + " National Park, " + thisParksCampgroundList[campgroundIndex].Name + " Campground");
            Console.WriteLine("Site No.".PadRight(10) + "Max Occup.".PadRight(12) + "Accessible?".PadRight(15) + "Max RV Length".PadRight(15)
                              + "Utility".PadRight(10) + "Cost");

            int numOfDaysStaying = (Convert.ToDateTime(endDate) - Convert.ToDateTime(startDate)).Days;

            for (int i = 0; i < availableCampsites.Count - 1; i++)
            {
                Console.WriteLine(availableCampsites[i].SiteNumber.ToString().PadRight(10) + availableCampsites[i].MaxOccupancy.ToString().PadRight(12) +
                                  availableCampsites[i].HandicapAccessible.ToString().PadRight(15) + availableCampsites[i].MaxRVLength.ToString().PadRight(15) +
                                  availableCampsites[i].HasUtilities.ToString().PadRight(10) + (numOfDaysStaying * thisParksCampgroundList[campgroundIndex].DailyFee / 100).ToString("C2"));
            }

            ReserveSelectedCampsite(availableCampsites, startDate, endDate);

            return(false);
        }