public bool DisplayReservationMenu()
        {
            //ParkReservationDAL parkReservationDAL = new ParkReservationDAL(connectionString);
            Console.WriteLine("Which Campground? (Press 0 to Cancel)");
            int selection = CLIHelper.GetInteger();

            if (selection == 0)
            {
                return(false);
            }
            else
            {
                _userChoiceCampground = _userChoiceCampgroundList[selection - 1];

                Console.WriteLine();
                Console.WriteLine("What is the Arrival Date? mm/dd/yyyy");
                arrivalDate = CLIHelper.GetDate(Console.ReadLine());
                Console.WriteLine("What is the Departure Date? mm/dd/yyyy");
                departureDate = CLIHelper.GetDate(Console.ReadLine());
                //List<CampSite> campSites = parkReservationDAL.GetCampSitesInCampGround(userCampground);
                List <CampSite> reservations = parkReservationDAL.GetAvailableReservations(_userChoiceCampground, arrivalDate, departureDate);
                amtOfDays = (departureDate - arrivalDate).Days;
                DisplayCampsites(reservations);
                DisplayReservationCommands(reservations);
                return(true);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Method gives user the options to Reserve a campsite and enter dates
        /// It will return an error if they try to book a site that already has an existing booking
        /// of any duration of overlapping days
        /// </summary>
        /// <param name="parkId"></param>
        public void CampgroundReservation(int parkId)
        {
            Console.Clear();
            Header();
            Console.WriteLine("Search for Campground Reservation");

            List <int> campgroundIds = ParkCampgrounds(parkId);

            bool timeToExit = false;

            while (!timeToExit)
            {
                int campId = CLIHelper.GetInteger("Which campground (enter 0 to cancel)?");

                if (campId == 0)
                {
                    timeToExit = true;
                    return;
                }
                if (campgroundIds.Contains(campId))
                {
                    DateTime arriveDate = CLIHelper.GetDate("What is the arrival date (YYYY/MM/DD)? ");
                    DateTime departDate = CLIHelper.GetDate("What is the departure date (YYYY/MM/DD)? ");
                    timeToExit = true;
                    DisplayAvailableSites(campId, arriveDate, departDate);
                }
                else
                {
                    Console.WriteLine("Please enter a valid option.");
                }
            }
        }
Esempio n. 3
0
        private void SearchForAvailableReservations(int ParkID)
        {
            string      CampgroundChoice = CLIHelper.GetString("Which campground would you like?");
            string      ArrivalDate      = CLIHelper.GetDate("What is the arrival date?");
            string      DepartureDate    = CLIHelper.GetDate("What is the departure date?");
            SiteDAL     sdal             = new SiteDAL(DatabaseConnection);
            List <Site> slist            = sdal.ViewAvailReservations(CampgroundChoice, ArrivalDate, DepartureDate);

            if (slist.Count > 0)
            {
                CampgroundDAL cgdal         = new CampgroundDAL(DatabaseConnection);
                double        camgroundCost = cgdal.GetCampgroundCost(CampgroundChoice);
                Console.WriteLine("Available sites & details for your dates:");
                Console.WriteLine("Site ID" + " " + "Max Occupancy" + " " + "Accessible?" + " " + "Max RV Length" + " " + "Utilities" + " " + "Cost");

                foreach (Site item in slist)
                {
                    Console.Write("   " + item.site_id.ToString().PadRight(9) + " " + item.max_occupancy.ToString().PadRight(10) + " " + TrueFalse(item.accessible).ToString().PadRight(14) + " " + item.max_rv_length.ToString().PadRight(10) + " " + TrueFalse(item.utilities).ToString().PadRight(8) + " " + camgroundCost);
                    Console.WriteLine();
                }

                string siteChoiceToReserve = CLIHelper.GetString("Which site should be reserved (enter 0 to cancel)");

                if (siteChoiceToReserve == "0")
                {
                    return;
                }

                bool SiteIsInTheList = false;

                foreach (Site item in slist)
                {
                    if (item.site_id.ToString() == siteChoiceToReserve)
                    {
                        SiteIsInTheList = true;
                    }
                }

                if (!SiteIsInTheList)

                {
                    Console.WriteLine("Sorry, that Site ID isn't in our list!  Please start over.");
                    return;
                }

                string name = CLIHelper.GetString("What name should the reservation be made under?");
                MakeReservation(siteChoiceToReserve, name, ArrivalDate, DepartureDate);
            }
            else
            {
                Console.WriteLine("Sorry, no campsites are available. Please try again with different dates.");
                return;
            }
        }
Esempio n. 4
0
        private void DisplayReservationMenu(Park park)
        {
            bool exit = false;

            while (!exit)
            {
                Console.Clear();
                Console.WriteLine();
                Console.WriteLine("Search for Campground Reservation");
                Console.WriteLine();
                Console.WriteLine(string.Format("{0, -4}{1, -20}{2, -20}{3, -20}{4, -20}", "", "Name", "Open", "Close", "Daily Fee"));
                DisplayCampgrounds(park);
                Console.WriteLine();
                int campgroundId = CLIHelper.GetInteger("Choose a campground ? (enter 0 to cancel)");

                if (campgroundId == 0)
                {
                    exit = true;
                }
                else
                {
                    while (!exit)
                    {
                        _arrivalDate = CLIHelper.GetDate("What is the arrival date? (MM/DD/YYYY)");
                        exit         = ValidateArrivalDate(_arrivalDate);
                    }

                    exit = false;

                    while (!exit)
                    {
                        _departureDate = CLIHelper.GetDate("What is the departure date? (MM/DD/YYYY)");
                        exit           = ValidateDepartureDate(_departureDate);
                    }

                    exit = false;
                    int     numDays   = (int)(_departureDate - _arrivalDate).TotalDays + 1;
                    decimal totalCost = CalculateCost(campgroundId, numDays);
                    while (!exit)
                    {
                        Console.WriteLine();
                        Console.WriteLine(string.Format("{0, -10}{1, -22}{2, -20}{3, -20}{4, -20}{5, -20}", "Site No.", "Max Occup.", "Max RV Length", "Accessible?", "Utilities", "Cost"));
                        DisplayCampgroundSites(campgroundId, _arrivalDate, _departureDate);
                        Console.WriteLine();
                        int inputNum = CLIHelper.GetInteger("Which site should be reserved? (Enter 0 to cancel)");

                        if (inputNum == 0)
                        {
                            exit = true;
                        }

                        else
                        {
                            //Console.WriteLine("What name should the reservation be made under?");
                            //string resName = Console.ReadLine();
                            string resName    = CLIHelper.GetString("What name should the reservation be made under?");
                            int    confirmNum = _reservationDAL.BookReservation(inputNum, _arrivalDate, _departureDate, resName);
                            Console.WriteLine();
                            Console.WriteLine();
                            Console.WriteLine($"The reservation has been made and the confirmation number is {confirmNum}");
                            Console.ReadKey();
                            Environment.Exit(0);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        // Search for and/or make site reservations
        public void SearchReservations()
        {
            selectedCampgroundId   = 0;
            selectedCampgroundName = "";
            selectedCampgroundCost = 0;



            //Search for Available Reservation
            Console.Clear();
            IList <Campground> campInfo = campgroundDAO.ReadToListCampground(selectedParkId);

            Console.WriteLine("Park Campgrounds");
            Console.WriteLine();
            Console.WriteLine(selectedParkName + " National Park Campgrounds");
            Console.WriteLine();
            Console.WriteLine("{0,-40}{1,-15}{2,-15}{3,-15}", "Name", "Open", "Close", "Daily Fee");

            for (int i = 0; i < campInfo.Count; i++)
            {
                Console.WriteLine("{0,-40}{1,-15}{2,-15}{3,-15:C}", i + 1 + ") " + campInfo[i].Name, CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(campInfo[i].OpenFrom), CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(campInfo[i].OpenTo), campInfo[i].DailyFee);
            }

            Console.WriteLine();


            string inputCampground = CLIHelper.GetString("Select a campground (enter Q to quit and return to main menu)");

            if (inputCampground.ToUpper() == "Q")
            {
                Console.Clear();
                RunParkMenu();
            }
            try
            {
                int pInputCampground = int.Parse(inputCampground) - 1;

                selectedCampgroundId   = campInfo[pInputCampground].CampgroundId;
                selectedCampgroundName = campInfo[pInputCampground].Name;
                selectedCampgroundCost = campInfo[pInputCampground].DailyFee;
            }

            catch (Exception)
            {
                Console.WriteLine("Not a valid campground; please press any key to try again");
                Console.ReadLine();
                SearchReservations();
            }

            bool datesAreValid = false;

            while (!datesAreValid)
            {
                Console.WriteLine();
                inputStartDate = CLIHelper.GetDate("What is the arrival date? (mm/dd/yyyy): ");
                inputEndDate   = CLIHelper.GetDate("What is the departure date? (mm/dd/yyyy): ");

                // Calculate number of days for reservation
                numDays = inputEndDate.Subtract(inputStartDate);
                intDays = numDays.TotalDays;
                if (inputStartDate < DateTime.Now)
                {
                    Console.WriteLine();
                    Console.WriteLine("Arrival/departure dates must be in the future. We do not have time-traveling capabilities.\nPlease try new dates.");
                }
                else if (intDays < 1)
                {
                    Console.WriteLine();
                    Console.WriteLine("Departure date must be after arrival date. \nPlease try new dates.");
                }
                else
                {
                    datesAreValid = true;
                }
            }



            // Display results matching search
            IList <Site> siteAvailList = siteDAO.ReadToListSite(selectedCampgroundId, inputStartDate, inputEndDate);

            Console.Clear();
            Console.WriteLine("Results Matching Your Search Criteria");
            Console.WriteLine();
            if (siteAvailList.Count == 0)
            {
                Console.WriteLine("No sites are available for your dates. Would you like to enter alternate dates? Y/N");
                string yesOrNo;
                bool   isValid = false;

                do
                {
                    yesOrNo = Console.ReadLine();
                    if (yesOrNo.ToUpper() != "Y" && yesOrNo.ToUpper() != "N")
                    {
                        Console.WriteLine("Please enter Y or N.");
                    }
                    else
                    {
                        isValid = true;
                    }
                }while (!isValid);

                if (yesOrNo.ToUpper() == "N")
                {
                    Console.Clear();
                    RunParkMenu();
                }
                else if (yesOrNo.ToUpper() == "Y")
                {
                    SearchReservations();
                }
            }
            else
            {
                string totalCost = $"Total Cost for {intDays} Days";
                Console.WriteLine("{0,-40}{1,-13}{2,-15}{3,-15}{4,-15}{5,-25}{6,-10}", "Campground", "Site No.", "Max Occup.", "Accessible?", "RV Length", "Utilities Available?", totalCost);
                List <int> validSiteIds = new List <int>();
                foreach (Site slot in siteAvailList)
                {
                    decimal campTotal = selectedCampgroundCost * (decimal)intDays;
                    Console.WriteLine("{0,-40}{1,-13}{2,-15}{3,-15}{4,-15}{5,-25}{6,-10:C}", selectedCampgroundName, +slot.SiteId, slot.MaxOccupancy, slot.Accessible, slot.MaxRvLength, slot.Utilities, campTotal);
                    validSiteIds.Add(slot.SiteId);
                }

                // check input against site numbers in the list

                bool inputInvalid = true;
                while (inputInvalid)
                {
                    Console.WriteLine();
                    inputSiteReserve = CLIHelper.GetInteger("Which site should be reserved? Enter site number from above list or 0 to start over: ");
                    if (inputSiteReserve == 0)
                    {
                        SearchReservations();
                        break;
                    }
                    else if (validSiteIds.Contains(inputSiteReserve))
                    {
                        inputInvalid = false;
                    }
                }

                inputNameReserve = CLIHelper.GetString("What name should the reservation be made under?");

                // Add reservation
                int id = reservationDAO.AddReservation(inputNameReserve, inputSiteReserve, inputStartDate, inputEndDate);

                if (id != 0)
                {
                    Console.Clear();
                    Console.WriteLine($"The reservation has been made, and the confirmation id is {id}");
                }
                else
                {
                    Console.WriteLine("Reservation unsuccessful.");
                    //option to go back
                }
                string inputContinue = "";
                while (inputContinue != "1" && inputContinue != "0")
                {
                    inputContinue = CLIHelper.GetString("Enter 1 to return to the main menu or 0 to quit");
                }
                if (inputContinue == "0")
                {
                    Environment.Exit(0);
                }
                else if (inputContinue == "1")
                {
                    Console.Clear();
                    RunParkMenu();
                }
            }
        }