예제 #1
0
        /// <summary>
        /// Books a reservation at site of choice.
        /// </summary>
        /// <param name="sites">A list of sites to choose from.</param>
        /// <param name="startDate">Start date of the reservation.</param>
        /// <param name="endDate">Reservation end date.</param>
        private void BookAReservation(List <Site> sites, DateTime startDate, DateTime endDate)
        {
            //Get user choice of site
            Console.WriteLine("Which site should be reserved (enter 0 to cancel) ");
            int input = CLIHelper.GetAnInteger(0, sites.Count);

            //If they chose a site number, get their name and book a reservation
            if (input != 0)
            {
                Console.WriteLine("What Name should the reservation be made under? ");
                string name = CLIHelper.GetString();

                Reservation reservation = new Reservation()
                {
                    SiteId   = sites[input - 1].SiteId,
                    Name     = name,
                    FromDate = startDate,
                    ToDate   = endDate
                };

                //Log reservation in the database
                int resId = resDAL.MakeReservation(reservation);

                //Show the user their confirmation ID
                Console.WriteLine();
                Console.WriteLine($"The Reservation has been made and your confirmation Id is {resId}");
                Console.WriteLine("Press any key to continue");
                Console.ReadKey(true);
                Console.Clear();
            }
        }
예제 #2
0
        /// <summary>
        /// Prints the campground menu
        /// </summary>
        /// <param name="currentPark">The park to look in</param>
        /// <returns>The user's input</returns>
        private int PrintCampgroundMenu(Park currentPark)
        {
            Console.Clear();
            // Print a list  Campgrounds
            PrintCampgroundList(currentPark);
            Console.WriteLine("Choose an option");
            Console.WriteLine("   1) Search for Available Reservation");
            Console.WriteLine("   2) Return to Previous Screen");
            Console.WriteLine();
            Console.Write("  >");

            // Return the user input
            return(CLIHelper.GetAnInteger(Command_SearchCampgroundReservation, Command_QuitCampgroundMenu));
        }
예제 #3
0
        /// <summary>
        /// Prints the Park menu
        /// </summary>
        /// <param name="currentPark">The park to display</param>
        /// <returns>The user's input</returns>
        private static int PrintParkMenu(Park currentPark)
        {
            Console.Clear();
            Console.WriteLine(currentPark.ToString());
            Console.WriteLine();
            Console.WriteLine("Choose an option");
            Console.WriteLine(" 1) View Campgrounds");
            Console.WriteLine(" 2) Search for Reservation");
            Console.WriteLine(" 3) View Upcoming Reservations");
            Console.WriteLine(" 4) View Current Campers");
            Console.WriteLine(" 5) Return to Previous Screen");
            Console.Write(" > ");

            // Return user input
            return(CLIHelper.GetAnInteger(Command_ViewCampgrounds, Command_QuitParkMenu));
        }
예제 #4
0
        /// <summary>
        /// Displays the main Menu
        /// </summary>
        /// <returns>The user's choice</returns>
        private static int PrintMainMenu()
        {
            Console.Clear();
            Console.WriteLine("Pick a Park to View");
            Console.WriteLine();

            //Get a list of park objects from ParkDAL
            List <Park> parks = parkDAL.GetParks();

            //Display each park name, and the quit option
            for (int i = 1; i <= parks.Count; i++)
            {
                Console.WriteLine($" {i}) {parks[i - 1].Name}");
            }
            Console.WriteLine($" {parks.Count + 1}) Quit");
            Console.WriteLine();
            Console.Write(" > ");

            // Return the user's input
            return(CLIHelper.GetAnInteger(1, parks.Count + 1));
        }
예제 #5
0
        /// <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);
            }
        }