예제 #1
0
        private List <AvailableReservations> GetAdditionalRequirements(List <AvailableReservations> reservations)
        {
            string needsRequirements = "";

            Console.WriteLine();
            Console.WriteLine("Do you have any additional requirements? (Y/N)");
            needsRequirements = cliHelper.GetString();
            while (needsRequirements.ToLower() != "y" && needsRequirements.ToLower() != "n")
            {
                Console.WriteLine("Invalid option. Please try again.");
                needsRequirements = cliHelper.GetString();
            }
            if (needsRequirements.ToLower() == "y")
            {
                int  maxOccupancy = 0;
                bool isAccessible = false;
                int  rvLength     = 0;
                bool utilities    = false;

                Console.WriteLine();
                Console.WriteLine("How many people are you expecting?");
                maxOccupancy = cliHelper.GetInteger();
                while (maxOccupancy <= 0)
                {
                    Console.WriteLine("Invalid option. Please try again");
                    maxOccupancy = cliHelper.GetInteger();
                }
                reservations = reservations.Where(r => r.MaxOccupancy >= maxOccupancy).ToList();

                Console.WriteLine();
                Console.WriteLine("Do you require wheelchair accessibility? (True/False)");
                isAccessible = cliHelper.GetBool();
                reservations = reservations.Where(r => r.Accessible == isAccessible).ToList();

                Console.WriteLine();
                Console.WriteLine("What is the length of your RV? Press 0 if you don't have an RV.");
                rvLength = cliHelper.GetInteger();
                while (rvLength < 0)
                {
                    Console.WriteLine("Invalid option. Please try again");
                    rvLength = cliHelper.GetInteger();
                }
                reservations = reservations.Where(r => r.MaxRvLenth <= rvLength).ToList();

                Console.WriteLine();
                Console.WriteLine("Do you require a utility setup? (True/False)");
                utilities    = cliHelper.GetBool();
                reservations = reservations.Where(r => r.Utilities == utilities).ToList();
            }
            return(reservations);
        }
        /// <summary>
        /// Gets the reservation info from the user
        /// </summary>
        /// <param name="reservation">This is the object to add reservation info to. It already has campsite id populated.</param>
        /// <returns>The passed in reservation info with extra fields populated</returns>
        private ReservationInfo GetReservationInfo(ReservationInfo reservation)
        {
            bool validSelection = false;

            while (!validSelection)
            {
                reservation.FromDate = CLIHelper.GetDateTime("What is the arrival date  (mm/dd/yyyy)?");
                if (reservation.FromDate < DateTime.Now)
                {
                    Console.WriteLine("The arrival date cannot be earlier than today.");
                    var isTryAgain = CLIHelper.GetString(Message_ReEnterArrivalDate);
                    if (isTryAgain.ToLower() == "n")
                    {
                        throw new ExitException();
                    }
                }
                else
                {
                    validSelection = true;
                }
            }

            validSelection = false;
            while (!validSelection)
            {
                reservation.ToDate = CLIHelper.GetDateTime("What is the departure date (mm/dd/yyyy)?");
                if (reservation.ToDate < reservation.FromDate)
                {
                    Console.WriteLine("The departure date cannot be earlier than the arrival date.");
                    var isTryAgain = CLIHelper.GetString(Message_ReEnterDepartureDate);
                    if (isTryAgain.ToLower() == "n")
                    {
                        throw new ExitException();
                    }
                }
                else if ((reservation.ToDate - reservation.FromDate).Days <= 0)
                {
                    Console.WriteLine("The reservation length must be at least 1 day or more.");
                    var isTryAgain = CLIHelper.GetString(Message_ReEnterDepartureDate);
                    if (isTryAgain.ToLower() == "n")
                    {
                        throw new ExitException();
                    }
                }
                else
                {
                    validSelection = true;
                }
            }

            reservation.Occupancy    = CLIHelper.GetInteger("What are your occupancy requirements (1-55)?", 1, 55);
            reservation.IsAccessible = CLIHelper.GetBool("Do you need handicap accessiblity (true/false)?");
            reservation.HasUtilities = CLIHelper.GetBool("Do you need utilities (true/false)?");
            reservation.RvLength     = CLIHelper.GetInteger("What is your minimum RV length requirements (0-35)?", 0, 35);

            return(reservation);
        }
예제 #3
0
        public void CampgroundReservationScreen(Park currentWorkingPark)
        {
            string campgroundSelectionPrompt = "\nPlease select a 'Campground' ID from the list (enter 0 to cancel)?";

            string campsiteSelectionPrompt = "\nPlease select a 'Campsite ID' from the list (enter 0 to cancel)?";

            string enterValidIDError = "Please make a valid 'Campsite ID' selection from the list.";

            string arrivalDatePrompt = "What is the arrival date? (MM/DD/YYYY):";

            string departureDatePrompt = "What is the departure date? (MM/DD/YYYY):";

            string negativeDateRangeError = "Departure date must be after arrival date. Please try again.\n";

            string noResultsInRangeError = "\nThere are no open campsites in the selected timeframe for that campground.\nTry an alternative date range.";

            string reservationNamePrompt = "What name should the reservation be made under?";

            string searchResult = $"Results Matching Your Search Criteria\n\n" + "Site #".PadRight(9) + "Max Occup.".PadRight(11) + "Accessible?".PadRight(12) + "RV Size".PadRight(12) + "Utility".PadRight(15) + "Cost\n";

            string reqFromDate;             //User desired arrival date

            string reqToDate;               //User desired departure date

            bool isFirstTry = true;         //Used to track first run through campground selection process


            IList <Campground> campgroundList   = DisplayCampgrounds(currentWorkingPark);
            List <int>         campgroundIdList = new List <int>();

            foreach (Campground campground in campgroundList)
            {
                campgroundIdList.Add(campground.Campground_id);
            }

            IList <Site> unreservedSites = new List <Site>();

            do
            {
                bool negativeDateRangeAttempted = false;

                if (!isFirstTry)
                {
                    Console.WriteLine(noResultsInRangeError);
                }

                int campgroundNum;          //Stores DB value for campgroundID

                do
                {
                    campgroundNum = CLIHelper.GetInteger(campgroundSelectionPrompt); //CLIHelper deals with incorrect inputs, do while just waits for proper input or exit condition

                    if (campgroundNum == 0)
                    {
                        return;
                    }
                } while (!campgroundIdList.Contains(campgroundNum));

                reqFromDate = CLIHelper.GetDateTime(arrivalDatePrompt); //Arrival date is necessarry and CLIHelper handles errors, so no loop necessary

                do
                {
                    if (negativeDateRangeAttempted)
                    {
                        Console.WriteLine(negativeDateRangeError);
                    }

                    reqToDate = CLIHelper.GetDateTime(departureDatePrompt);

                    negativeDateRangeAttempted = DateTime.Parse(reqToDate) <= DateTime.Parse(reqFromDate);
                } while (negativeDateRangeAttempted);

                /*----------------------------------------------------Advanced Search------------------------------------------------------*/
                bool advancedSearch = false;  //TODO Any way to move this to its own method?
                int  minOccupancy   = 0;
                bool accessible     = false;
                int  maxRvLength    = 0;
                bool utilities      = false;

                advancedSearch = CLIHelper.GetBool("Use Advanced Search (Y/N)?");

                if (advancedSearch)
                {
                    minOccupancy = CLIHelper.GetInteger("Minimum Occupancy (Enter 0 to skip):");
                    accessible   = CLIHelper.GetBool("Do you require accessibility features (Y/N)?");
                    maxRvLength  = CLIHelper.GetInteger("What is your RV size (Enter 0 to skip)?");
                    utilities    = CLIHelper.GetBool("Do you require a utility hookup (Y/N)?");
                }
                /*---------------------------------------------------End of Advanced Search-------------------------------------------------*/

                SiteDAL siteDal = new SiteDAL(DatabaseConnection);
                unreservedSites = siteDal.GetUnreservedCampsites(reqFromDate, reqToDate, campgroundNum, minOccupancy, accessible, maxRvLength, utilities);

                isFirstTry = false;
            } while (unreservedSites.Count == 0);

            int lengthOfStay = CLIHelper.GetLengthOfStay(reqFromDate, reqToDate);

            Console.Clear();
            Console.WriteLine(searchResult);

            foreach (Site site in unreservedSites)
            {
                Console.WriteLine(site.ToString(lengthOfStay, false));
            }

            ReservationDAL reservationDAL = new ReservationDAL(DatabaseConnection);

            while (true)
            {
                int campsiteChoice = CLIHelper.GetInteger(campsiteSelectionPrompt);

                if (campsiteChoice == 0)
                {
                    return;
                }

                foreach (Site site in unreservedSites)
                {
                    if (campsiteChoice == site.SiteID)
                    {
                        string reservationHeader = $"===================Reservation Confirmation==================\n";

                        string reservationName = CLIHelper.GetString(reservationNamePrompt);
                        int    reservationID   = reservationDAL.MakeReservation(reqFromDate, reqToDate, campsiteChoice, reservationName);

                        Console.Clear();
                        Console.SetCursorPosition((Console.WindowWidth - reservationHeader.Length) / 2, Console.CursorTop);
                        Console.WriteLine(reservationHeader);
                        Console.WriteLine($"\nThe reservation has been made and the confirmation id is {reservationID}.\nPress Enter to continue."); //Can't move this yet
                        Console.ReadLine();
                        return;
                    }
                }

                Console.WriteLine(enterValidIDError);
            }
        } //Used to view open reservations and make reservations in the scope of a campsite at a campground
예제 #4
0
        public void ParkWideAvailabilitySearch(int parkID)
        {
            string reqFromDate;

            string reqToDate;

            string reservationHeader = $"===================Reservation Confirmation==================\n";

            bool isFirstTry = true;

            IList <Campground> campgroundList = new List <Campground>();
            List <Site>        masterSiteList = new List <Site>();
            CampgroundDAL      campgroundDAL  = new CampgroundDAL(DatabaseConnection);

            campgroundList = campgroundDAL.GetCampgroundList(parkID);

            do
            {
                if (!isFirstTry)
                {
                    Console.WriteLine("\nThere are no open campsites in the selected timeframe for that park.\nTry an alternative date range.");
                }

                //TODO: consolidate getDateRange into CLI helper method that returns two string dates once validated

                reqFromDate = CLIHelper.GetDateTime("What is the arrival date? (MM/DD/YYYY):");

                bool negativeDateRangeAttempted = false;

                do
                {
                    if (negativeDateRangeAttempted)
                    {
                        Console.WriteLine("Departure date must be after arrival date. Please try again.\n");
                    }
                    reqToDate = CLIHelper.GetDateTime("What is the departure date? (MM/DD/YYYY):");

                    negativeDateRangeAttempted = DateTime.Parse(reqToDate) <= DateTime.Parse(reqFromDate);
                } while (negativeDateRangeAttempted);


                /*----------------------------------------------------Advanced Search------------------------------------------------------*/
                bool advancedSearch = false;
                int  minOccupancy   = 0;
                bool accessible     = false;
                int  maxRvLength    = 0;
                bool utilities      = false;

                advancedSearch = CLIHelper.GetBool("Use Advanced Search (Y/N)?");

                if (advancedSearch)
                {
                    minOccupancy = CLIHelper.GetInteger("Minimum Occupancy (Enter 0 to skip):");
                    accessible   = CLIHelper.GetBool("Do you require accessibility features (Y/N)?");
                    maxRvLength  = CLIHelper.GetInteger("What is your RV size (Enter 0 to skip)?");
                    utilities    = CLIHelper.GetBool("Do you require a utility hookup (Y/N)?");
                }
                /*---------------------------------------------------End of Advanced Search-------------------------------------------------*/


                foreach (Campground campground in campgroundList)
                {
                    IList <Site> campgroundSiteList = new List <Site>();
                    SiteDAL      siteDAL            = new SiteDAL(DatabaseConnection);

                    campgroundSiteList = siteDAL.GetUnreservedCampsites(reqFromDate, reqToDate, campground.Campground_id, minOccupancy, accessible, maxRvLength, utilities);

                    foreach (Site site in campgroundSiteList)
                    {
                        site.CampgroundName = campground.Name;
                    }
                    masterSiteList.AddRange(campgroundSiteList); //Uses the SQL query on all campgrounds in a park to return top 5 campsites in all campgrounds
                }

                isFirstTry = false;
            } while (masterSiteList.Count == 0);

            int lengthOfStay = CLIHelper.GetLengthOfStay(reqFromDate, reqToDate);

            Console.Clear();
            Console.WriteLine($"Results Matching Your Search Criteria\n\n" + "Campground".PadRight(22) + "Site #".PadRight(10) + "Max Occup.".PadRight(13) + "Accessible?".PadRight(12) + "RV Size".PadRight(12) + "Utility".PadRight(15) + "Cost\n");
            foreach (Site site in masterSiteList)
            {
                Console.WriteLine(site.ToString(lengthOfStay, true));
            }

            ReservationDAL reservationDAL = new ReservationDAL(DatabaseConnection);

            while (true)
            {
                int campsiteChoice = CLIHelper.GetInteger("\nPlease select your desired Site # from the list (enter 0 to cancel)?");
                if (campsiteChoice == 0)
                {
                    return;
                }

                foreach (Site site in masterSiteList)
                {
                    if (campsiteChoice == site.SiteID)
                    {
                        string reservationName = CLIHelper.GetString("What name should the reservation be made under?");
                        int    reservationID   = reservationDAL.MakeReservation(reqFromDate, reqToDate, campsiteChoice, reservationName);
                        Console.Clear();
                        Console.SetCursorPosition((Console.WindowWidth - reservationHeader.Length) / 2, Console.CursorTop);
                        Console.WriteLine(reservationHeader);
                        Console.WriteLine($"\nThe reservation has been made and the confirmation id is {reservationID}.\nPress Enter to continue.");
                        Console.ReadLine();
                        return;
                    }
                }

                Console.WriteLine("Please make a valid campsite ID selection from the list.");
            }
        } //Searches availability for every campground in a given park