コード例 #1
0
        /// <summary>
        /// Runs the menu
        /// </summary>
        public override void Run()
        {
            IList <Campground> campgrounds = campgroundDAO.GetCampgrounds(park.Id);

            this.CampgroundMenuHeader(campgrounds);
            DisplayCampgroundOptions();

            while (true)
            {
                int userInput = GetInteger("Pick One:", 0, campgrounds.Count);

                if (userInput == 1)
                {
                    this.CampgroundMenuHeader(campgrounds);

                    int selectedCampground = GetInteger("Which campground (enter 0 to cancel)?", -1, campgrounds.Count);
                    if (selectedCampground == 0)
                    {
                        break;
                    }

                    DateTime arrivalDate   = GetDate("What is the arrival date (mm/dd/yyyy)?");
                    DateTime departureDate = GetDate("What is the departure date (mm/dd/yyyy)?");
                    Console.WriteLine();

                    // List of all Avaiable sites
                    IList <Site> sites = this.siteDAO.GetSites(campgrounds[selectedCampground - 1].Id, arrivalDate, departureDate);

                    // Displays site results
                    Console.WriteLine("Site No.".PadRight(SitePad) + "Max Occup.".PadRight(SitePad) + "Accessible?".PadRight(SitePad) + "Max RV Length".PadRight(SitePad) + "Utilty".PadRight(SitePad) + "Cost");
                    foreach (Site site in sites)
                    {
                        decimal cost = campgroundDAO.GetCampingCost(campgrounds[selectedCampground - 1].DailyFee, arrivalDate, departureDate);
                        Console.WriteLine($"{site.SiteNumber, -SitePad}{site.MaxOccupancy, -SitePad}{site.Accessible, -SitePad}{site.MaxRVLength, -SitePad}{site.Utilities, -SitePad}{cost:C2}");
                    }

                    // Book reservation
                    Console.WriteLine();
                    int    siteNumber      = GetInteger("Which site should be reserved (enter 0 to cancel)?");
                    string reservationName = GetString("What name should the reservation be made under?");

                    reservationDAO.GetReservations(sites[siteNumber - 1].SiteId);
                    Reservation newReservation = Reservation.CreateReservation(sites[siteNumber - 1].SiteId, arrivalDate, departureDate, reservationName);
                    int         reservationId  = reservationDAO.BookResrevation(newReservation);

                    Console.Write($"The reservation has been made and the confirmation id is {reservationId}");
                    Console.ReadLine();
                    CampgroundMenuHeader(campgrounds);
                    DisplayCampgroundOptions();
                }
                else if (userInput == 2)
                {
                    break;
                }
                else
                {
                    InvalidInput();
                }
            }
        }
コード例 #2
0
        public void DisplayReservations(int selectedParkId)
        {
            Console.Clear();
            IList <Reservation> reservations = reservationDAO.GetReservations(selectedParkId);

            Console.WriteLine("Campgound                       Site Number        From          To");
            foreach (Reservation reservation in reservations)
            {
                int    siteNumber     = siteDAO.GetSiteNumber(reservation.SiteId);
                string campgroundName = campgroundDAO.GetCampgroundName(reservation.SiteId);

                Console.WriteLine("{0,-30}       {1,-5}       {2,-10}    {3,-10}", campgroundName, siteNumber, (reservation.FromDate).ToString("yyyy/MM/dd"), (reservation.ToDate).ToString("yyyy/MM/dd"));
            }

            Console.WriteLine();
            Console.WriteLine("Press ENTER to go back.");
            Console.ReadLine();
            Console.Clear();
            ParkDescription();
            MainMenu();
        }
コード例 #3
0
        public void SearchAndMakeReservationMenu(int venueNum)
        {
            venueNum += 1;
            IList <Venue>       venues       = venueDAO.GetVenues();
            IList <Space>       spaces       = spaceDAO.GetVenueSpaces(venueNum);
            IList <Reservation> reservations = reservationDAO.GetReservations(spaces);
            DateTime            startDate    = new DateTime();
            int numOfDays       = 0;
            int peopleAttending = 0;

            bool done = false;

            while (!done)
            {
                //different try catch statements for each parse check because a different error message is returned
                try
                {
                    Console.WriteLine("Search for available spaces");
                    Console.WriteLine("When do you need the space? MM/DD/YEAR");
                    string inputDay = Console.ReadLine();

                    startDate = DateTime.Parse(inputDay);
                    if (startDate < DateTime.Now)
                    {
                        Console.WriteLine("Please input a future date!");
                        return;
                    }
                }
                catch (System.FormatException)
                {
                    Console.WriteLine("Please enter your date as a Month Number/Day/Full Year");
                    return;
                }

                Console.WriteLine("How many days will you need the space?");
                string dayNumber = Console.ReadLine();
                try
                {
                    numOfDays = Convert.ToInt32(dayNumber);
                    if (numOfDays <= 0)
                    {
                        Console.WriteLine("Please input a positive number of days");
                        return;
                    }
                }
                catch (System.FormatException)
                {
                    Console.WriteLine("Please enter the length of your reservation as a number");
                    return;
                }

                Console.WriteLine("How many people will be in attendance?");
                string attendNum = Console.ReadLine();

                try
                {
                    peopleAttending = Convert.ToInt32(attendNum);
                    if (peopleAttending <= 0)
                    {
                        Console.WriteLine("Please input the number of people attending");
                        return;
                    }
                }
                catch (System.FormatException)
                {
                    Console.WriteLine("Please enter the expected attendance as a number");
                    return;
                }

                List <Space> toRemove = new List <Space>();
                //creates a list of items to remove from the list of Spaces - each bool check adds to the list
                foreach (Space space in spaces)
                {
                    bool available = reservationDAO.IsDateAvailable(reservations, space, startDate, numOfDays);
                    if (available == false)
                    {
                        toRemove.Add(space);
                    }
                }
                foreach (Space space in spaces)
                {
                    bool available = reservationDAO.IsSpaceOperating(space, startDate, numOfDays);
                    if (available == false)
                    {
                        toRemove.Add(space);
                    }
                }
                foreach (Space space in spaces)
                {
                    bool available = reservationDAO.IsBookingBelowMaxOcc(space, peopleAttending);
                    if (available == false)
                    {
                        toRemove.Add(space);
                    }
                }
                foreach (Space removal in toRemove)
                {
                    spaces.Remove(removal);
                }
                //removes all Space objects that are in the list toRemove from the list spaces

                Console.WriteLine("");
                Console.WriteLine("Space #".PadRight(9) + "Name".PadRight(25) + "Daily Rate".PadRight(12) +
                                  "Max Occup".PadRight(10) + "Accessible?".PadRight(12) + "Total Cost".PadRight(13));
                foreach (Space space in spaces)
                {
                    decimal totalCost = space.DailyRate * numOfDays;
                    Console.WriteLine(space.Id.ToString().PadRight(9) + space.Name.PadRight(25) +
                                      space.DailyRate.ToString("C").PadRight(12) + space.MaxOccupancy.ToString().PadRight(10) +
                                      space.IsAccessible.ToString().PadRight(12) + totalCost.ToString("C"));
                }
                Console.WriteLine("");
                Console.WriteLine("Which space would you like to reserve? (Please enter Space #)");
                string spaceIDChosen = Console.ReadLine();
                Console.WriteLine("Who is this reservation for?");
                string reservedFor = Console.ReadLine();

                //ADD METHOD TO GO TO CONFIRMATION AND TO ADD TO RESERVATION DATABASE
                PrintReservationConfirmation(venueNum, spaceIDChosen, reservedFor, startDate, numOfDays, peopleAttending);

                done = true;
            }
        }
コード例 #4
0
        /// <summary>
        /// Runs the national park reservation system
        /// </summary>
        public void Run()
        {
            //Get the list of parks from the database
            IList <Park> parks = parkDAO.GetAllParks();

            //The loop which keeps us in the menu system until you quit
            while (true)
            {
                //Displaying the main menu
                string mMInput = mainMenu.DisplayMenu(parks);

                //The check for a command to quit
                if (mMInput.ToLower() == "q")
                {
                    break;
                }

                //Converting the user's input into a specific park object
                int  parkID   = int.Parse(mMInput);
                Park userPark = parks[parkID - 1];

                //The loop which keeps us in the park info menu
                while (true)
                {
                    //Get the list of campgrounds in the park
                    IList <Campground> campgrounds = campgroundDAO.GetAllCampgroundsByPark(parkID);

                    //Display the park info menu
                    int pIInput = parkInfoMenu.DisplayMenu(userPark);

                    //Declaring the variable for input from the campground menu here so it persists outside the if statement where we visit that menu
                    int pCInput = 0;

                    //If the input on the park info menu is 1 we go to the campgrounds menu
                    if (pIInput == 1)
                    {
                        //Displaying the campgrounds menu
                        pCInput = parkCampgrounds.DisplayMenu(userPark, campgrounds);
                    }

                    //If you choose "Search for a Reservation" on either the park info or campground menu
                    if (pIInput == 2 || pCInput == 1)
                    {
                        //Creating a list that will store the the available sites
                        IList <Site> sites = new List <Site>();

                        //Creating a variable to store information returned from the "Display Menu" method of the reservation menu
                        int      campgroundID       = 0;
                        DateTime requestedStart     = new DateTime(1753, 01, 01);
                        DateTime requestedEnd       = new DateTime(1753, 01, 01);
                        bool     makeReservation    = true;
                        var      reservationRequest = (campground : campgroundID, from : requestedStart, to : requestedEnd, keepGoing : makeReservation);

                        //A boolean to control when we break out of these nested while loops
                        bool looper = false;

                        //The loop which keeps us in the Reservation Menu's display menu method
                        do
                        {
                            //Making sure this is false whenever we start the loop
                            looper = false;

                            //Displayinng the reservation menu
                            reservationRequest = reservationMenu.DisplayMenu(userPark, campgrounds); Campground thisCampground = new Campground();

                            //Making sure the requested stay is within the open season of the campground
                            if (reservationRequest.campground != 0)
                            {
                                //Getting this specific campground we are looking at
                                List <Campground> camps = new List <Campground>(campgrounds.Where(c => c.ID == reservationRequest.campground));
                                thisCampground = camps[0];

                                if (reservationRequest.from.Month < thisCampground.OpeningMonth || reservationRequest.to.Month > thisCampground.ClosingMonth)
                                {
                                    //Changing the control variable so we stay in this loop
                                    looper = true;
                                    //Displaying the out of range message
                                    reservationMenu.DateOutOfRange();
                                }
                            }

                            //Where we break if the user chooses to cancel
                            if (reservationRequest.keepGoing == false)
                            {
                                //changing the control variable so we return to the top menu
                                looper = true;
                                break;
                            }

                            //retreiving the list of available sites
                            sites = siteDAO.GetAvailableSites(parkID, reservationRequest.campground, reservationRequest.from, reservationRequest.to);
                            if (sites.Count == 0)
                            {
                                //changing the control variable
                                looper = true;

                                //telling the user there were no sites available and checking their choice of whther or not to continue
                                if (!reservationMenu.NoSitesAvailable())
                                {
                                    break;
                                }
                            }
                        } while (looper);

                        //If we display the make reservation menu
                        if (!looper)
                        {
                            //Creating a variable to store information returned from the "make reservation" method of the reservsation menu
                            int    selectedSite  = 0;
                            string camperName    = "";
                            bool   pressOnward   = true;
                            var    camperAndSite = (site : selectedSite, camper : camperName, keepGoing : pressOnward);

                            //Displaying the make reservation menu
                            camperAndSite = reservationMenu.MakeReservation(sites, campgrounds, reservationRequest);

                            //where we allow the user to quit
                            if (camperAndSite.keepGoing == false)
                            {
                                break;
                            }

                            //turning the user's input into a reservation object
                            Reservation newReservation = new Reservation();
                            newReservation.SiteID    = camperAndSite.site;
                            newReservation.Name      = camperAndSite.camper;
                            newReservation.StartDate = reservationRequest.from;
                            newReservation.EndDate   = reservationRequest.to;

                            //Storing the reservation in the database and returning the reservztion id
                            int reservationID = reservationDAO.MakeReservation(newReservation);

                            //Displaying the confirmation message
                            reservationMenu.ConfirmReservation(reservationID);
                            break;
                        }
                    }
                    //The input for return to previous screen
                    else if (pIInput == 3)
                    {
                        break;
                    }
                    //The choice for looking at upcoming reservations
                    else if (pCInput == 2)
                    {
                        //Displaying the upcoming reservations
                        parkCampgrounds.ShowReservations(reservationDAO.GetReservations(userPark));
                    }
                }
            }
        }