Esempio n. 1
0
        private void GetAllSitesForCampgroundCLI(Campground campground, DateTime userArrivalDate, DateTime userDepartureDate)
        {
            SiteDAL siteDAL = new SiteDAL(DatabaseConnection);

            List <Site> sites            = siteDAL.GetTopFiveAvailableSites(campground, userArrivalDate, userDepartureDate);
            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 ParkWideSearchCLI(Park park)
        {
            Console.WriteLine("UNDER CONSTRUCTION: Parkwide Search feature coming soon!");

            CampgroundDAL  campgroundDAL  = new CampgroundDAL(DatabaseConnection);
            SiteDAL        siteDAL        = new SiteDAL(DatabaseConnection);
            ReservationDAL reservationDAL = new ReservationDAL(DatabaseConnection);

            //Get start and end dates for reservation
            Dictionary <bool, DateTime> startDateTrueEndDateFalse = GetStartAndEndDates();
            DateTime userArrivalDate   = startDateTrueEndDateFalse[true];
            DateTime userDepartureDate = startDateTrueEndDateFalse[false];

            //Get all campgrounds for park
            List <Campground>            campgrounds          = campgroundDAL.GetAllCampgroundsForPark(park);
            Dictionary <int, Campground> campgroundDictionary = new Dictionary <int, Campground>();

            foreach (Campground item in campgrounds)
            {
                campgroundDictionary.Add(item.CampgroundId, item);
            }


            //Shit getting real BELOW!
            bool doneWithMenu = false;

            while (!doneWithMenu)
            {
                Console.Clear();

                string snName = "Available Park Sites 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();
                Console.WriteLine($"Reservation Start Date: {userArrivalDate.ToShortDateString()}");
                Console.WriteLine($"Reservation End Date: {userDepartureDate.ToShortDateString()}");

                Dictionary <int, Site> allSitesInPark = new Dictionary <int, Site>();
                int campgroundDisplayLoopCounter      = 0;
                foreach (Campground campground in campgrounds)
                {
                    //Write Header For Each Campground
                    Console.WriteLine();
                    if (campgroundDisplayLoopCounter == 0)
                    {
                        Console.WriteLine("---------------------------------------------------------------------------");
                    }
                    Console.WriteLine(campground.Name.ToUpper() + " CAMPGROUND");

                    //Check if Campground is Closed
                    bool campgroundOpen = true;
                    try
                    {
                        reservationDAL.IsCampgroundOpen(campground, userArrivalDate, userDepartureDate);
                    }
                    catch (Exception e)
                    {
                        campgroundOpen = false;
                        Console.WriteLine(e.Message);
                        Console.WriteLine();
                    }


                    List <Site> sites = siteDAL.GetTopFiveAvailableSites(campground, userArrivalDate, userDepartureDate);
                    if (sites.Count() > 0 && campgroundOpen)
                    {
                        Console.WriteLine("{0,-15}{1,-15}{2,-15}", "OPEN", "CLOSE", "DAILY FEE");
                        Console.WriteLine("{0,-15}{1,-15}{2,-15}", campground.GetMonthString(true), campground.GetMonthString(false), campground.DailyFee);
                        Console.WriteLine();

                        Console.WriteLine($"Reservation Total Fee: " + campground.CostOfStayForSite(userArrivalDate, userDepartureDate).ToString("c"));
                        Console.WriteLine();
                    }

                    if (sites.Count() > 5 && campgroundOpen)
                    {
                        for (int i = 1; i <= 5; i++)
                        {
                            if (i == 1)
                            {
                                Console.WriteLine("{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}", "SITE NO.", "MAX OCCUP.", "ACCESSIBLE", "RV LENGTH", "UTILITY");
                            }
                            Console.WriteLine("{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}", sites[i - 1].SiteId, sites[i - 1].MaxOccupancy, sites[i - 1].Accessible, sites[i - 1].MaxRVLength, sites[i - 1].Utilities);
                            allSitesInPark.Add(sites[i - 1].SiteId, sites[i - 1]);
                        }
                    }
                    else if (sites.Count() < 6 && sites.Count() > 0 && campgroundOpen)
                    {
                        for (int i = 1; i <= sites.Count(); i++)
                        {
                            if (i == 1)
                            {
                                Console.WriteLine("{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}", "SITE NO.", "MAX OCCUP.", "ACCESSIBLE", "RV LENGTH", "UTILITY");
                            }
                            Console.WriteLine("{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}", sites[i - 1].SiteId, sites[i - 1].MaxOccupancy, sites[i - 1].Accessible, sites[i - 1].MaxRVLength, sites[i - 1].Utilities);
                            allSitesInPark.Add(sites[i - 1].SiteId, sites[i - 1]);
                        }
                    }
                    else if (sites.Count() == 0 && campgroundOpen)
                    {
                        Console.WriteLine("There are no sites available at your selected campground on your selected dates :(");
                    }
                    Console.WriteLine("---------------------------------------------------------------------------");

                    campgroundDisplayLoopCounter++;
                }

                //Get user input

                List <int> siteIDs = new List <int>();
                foreach (KeyValuePair <int, Site> item in allSitesInPark)
                {
                    siteIDs.Add(item.Key);
                }
                string userSelection = CLIHelper.GetIntInListOrQ("Please enter a site ID to make a reservation or enter R to return to the Park Information Menu", siteIDs, "r", false);
                if (userSelection.ToLower() == "r")
                {
                    doneWithMenu = true;
                }
                else
                {
                    int        selectedSiteID     = int.Parse(userSelection);
                    Site       selectedSite       = allSitesInPark[selectedSiteID];
                    Campground selectedCampground = campgroundDictionary[selectedSite.CampgroundId];


                    MakeReservationCLI(selectedCampground, selectedSiteID, userArrivalDate, userDepartureDate);
                    doneWithMenu = true;
                }
            }
        }