Esempio n. 1
0
        private void AdvancedSearchGetSitesCLI(Campground campground, DateTime userArrivalDate, DateTime userDepartureDate)
        {
            //int numberOfCampers, bool needAccessible, int rvLength, bool needUtilities
            int  numberOfCampers = CLIHelper.GetInteger("Please enter the number of peoples");
            bool needAccessible  = CLIHelper.GetBoolCustom("Will you need your site to have handicap access?", "yes", "no");
            bool usingRV         = CLIHelper.GetBoolCustom("Will you be using an RV?", "yes", "no");
            int  rvLength        = 0;

            if (usingRV)
            {
                rvLength = CLIHelper.GetInteger("Please enter the length of your RV (ft)");
            }
            bool needUtilities = CLIHelper.GetBoolCustom("Will you need your site to have utility access?", "yes", "no");

            SiteDAL siteDAL = new SiteDAL(DatabaseConnection);

            List <Site> sites            = siteDAL.GetTopFiveAvailableSitesAdvancedSearch(campground, userArrivalDate, userDepartureDate, numberOfCampers, needAccessible, rvLength, needUtilities);
            bool        finishedWithMenu = false;

            while (!finishedWithMenu)
            {
                string input = DisplaySitesAndGetUserInput(sites, campground, userArrivalDate, userDepartureDate);

                Console.WriteLine();
                //Using user input
                if (input.ToLower() == "r")
                {
                    finishedWithMenu = true;
                }
                else if (input.ToLower() != "r" && input != "zzz")
                {
                    MakeReservationCLI(campground, int.Parse(input), userArrivalDate, userDepartureDate);
                }
                finishedWithMenu = true;
            }
        }
Esempio n. 2
0
        private void GetAllCampgroundsForParkCLI(Park park)
        {
            CampgroundDAL     campgroundDAL  = new CampgroundDAL(DatabaseConnection);
            ReservationDAL    reservationDAL = new ReservationDAL(DatabaseConnection);
            List <Campground> campgrounds    = campgroundDAL.GetAllCampgroundsForPark(park);
            bool doneWithMenu = false;

            while (!doneWithMenu)
            {
                Console.Clear();
                //Displaying menu items
                string snName = "Park Campground 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();

                for (int i = 1; i <= campgrounds.Count; i++)
                {
                    if (i == 1)
                    {
                        Console.WriteLine("{0,-5}{1,-35}{2,-10}{3,-10}{4,-10}", " ", "NAME", "OPEN", "CLOSE", "DAILY FEE");
                    }
                    Console.WriteLine("{0,-5}{1,-35}{2,-10}{3,-10}{4,-10}", i + ")", campgrounds[i - 1].Name, campgrounds[i - 1].GetMonthString(true), campgrounds[i - 1].GetMonthString(false), campgrounds[i - 1].DailyFee.ToString("c"));
                }
                Console.WriteLine($"");

                //Selecting a campground
                string userCampground = CLIHelper.GetIntInRangeOrQ("Which campground would you like to make a reservation at? [or press (Q) to quit]", 1, campgrounds.Count(), "q", true);
                Console.WriteLine();



                if (userCampground.ToLower() == "q")
                {
                    doneWithMenu = true;
                }
                else
                {
                    //Get Date and Time
                    Dictionary <bool, DateTime> startDateTrueEndDateFalse = GetStartAndEndDates();
                    DateTime userArrivalDate   = startDateTrueEndDateFalse[true];
                    DateTime userDepartureDate = startDateTrueEndDateFalse[false];
                    bool     datesGood         = false;
                    while (!datesGood)
                    {
                        bool campgroundOpen = true;
                        try
                        {
                            reservationDAL.IsCampgroundOpen(campgrounds[int.Parse(userCampground) - 1], userArrivalDate, userDepartureDate);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                            campgroundOpen = false;
                        }
                        if (campgroundOpen)
                        {
                            datesGood = true;
                        }
                    }


                    bool wantAdvancedSearch = CLIHelper.GetBoolCustom("Would you like to check additional site requirements with our advanced search?", "yes", "no");
                    if (wantAdvancedSearch)
                    {
                        AdvancedSearchGetSitesCLI(campgrounds[int.Parse(userCampground) - 1], userArrivalDate, userDepartureDate);
                    }
                    else if (!wantAdvancedSearch)
                    {
                        GetAllSitesForCampgroundCLI(campgrounds[int.Parse(userCampground) - 1], userArrivalDate, userDepartureDate);
                    }
                    doneWithMenu = true;
                }
            }
        }