private Site SelectSite(List <Site> availableSites, DateTime userFromDate, DateTime userToDate, Site potentialSite)
        {
            Console.WriteLine();
            int userInput = CLIHelper.GetInteger("Which site number should be reserved? (enter 0 to cancel)");

            //if input is zero, unpopulated Site is returned
            //else, loop through available sites and look for a match by site number

            if (userInput == 0)
            {
                return(potentialSite);
            }
            else
            {
                foreach (Site thisSite in availableSites)
                {
                    if (thisSite.SiteNumber == userInput)
                    {
                        potentialSite = thisSite;
                        Console.WriteLine();
                        Console.WriteLine($"Site {thisSite.SiteNumber} selected.");
                        Console.WriteLine();
                    }
                }
                if (potentialSite.SiteId != 0)
                {
                    string reservationName = CLIHelper.GetString("What name should the reservation be made under? ") + " Reservation";
                    AddReservation(potentialSite, userFromDate, userToDate, reservationName);
                }
            }
            return(potentialSite);
        }
Ejemplo n.º 2
0
        public void PrintMenu()
        {
            bool exit = false;

            while (!exit)
            {
                Console.Clear();
                PrintHeader();
                Console.WriteLine();
                Console.WriteLine("Select a park for more information or select '0' to quit.");
                DisplayParks();
                Console.WriteLine("0) Quit");
                int userInput = CLIHelper.GetInteger(" ");

                if (userInput == 0)
                {
                    exit = true;
                }
                else
                {
                    if (userInput > 0 && userInput <= _parks.Count)
                    {
                        DisplayParkMenu(_parks[userInput]);
                    }
                    else
                    {
                        Console.WriteLine("Please choose a valid option.");
                        Console.ReadKey();
                    }
                }
            }
        }
        public void BookReservation(Reservation r)
        {
            string name          = CLIHelper.GetString("Please enter first and last name:");
            int    siteNumber    = CLIHelper.GetInteger("Please enter the site number: ");
            int    numberCampers = CLIHelper.GetInteger("Please enter the number of campers:");

            int reservationID = 0;


            r.Name          = name;
            r.SiteNumber    = siteNumber;
            r.NumberCampers = numberCampers;


            ReservationSqlDAL dal = new ReservationSqlDAL();

            try
            {
                reservationID = dal.BookReservation(r);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            if (reservationID > 0)
            {
                Console.WriteLine($"Your reservation was successfully created. Reservation id: {reservationID}");
            }
            else
            {
                Console.WriteLine("Request unsuccessful. Reservation NOT created.");
            }
        }
        private void ShowAllCampgroundInAPark(int userInputParkId)
        {
            Console.WriteLine("Showing Campgrounds");

            CampgroundSqlDAL cal = new CampgroundSqlDAL(connectionString);

            List <Campground> allCampgrounds = cal.GetAllCampgrounds(userInputParkId);

            foreach (Campground c in allCampgrounds)
            {
                Console.WriteLine();
                Console.WriteLine("Campground_Id " + c.Campground_id);
                Console.WriteLine("Park ID: " + c.Park_id);
                Console.WriteLine("Campground Name: " + c.Name);
                Console.WriteLine("Campground is open from " + CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(c.Open_from_mm));
                Console.WriteLine("Campground closes at " + CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(c.Open_to_mm));
                Console.WriteLine("Campground daily cost: " + c.Daily_fee.ToString("C"));
            }

            Console.ReadLine();
            Console.WriteLine("Would you like to book  one of these sites? (Y/N)");
            string input = Console.ReadLine().ToUpper();

            if (input == "Y")
            {
                int campgroundId = CLIHelper.GetInteger("Please select a Campground ID");

                Reservation(campgroundId);
            }
            return;
        }
        public Park GoToMainMenu()
        {
            Console.Clear();
            //Greeting
            Console.WriteLine("Welcome to the Park Reservation System");
            Console.WriteLine("Please Select a Park for Further Details");


            //List of Parks
            //ParkReservationDAL parkReservationDAL = new ParkReservationDAL(connectionString);
            List <Park> listOfParks = parkReservationDAL.GetAllParks();
            //Adding the list of parks into a dictionary that the key (j) will start at 1
            Dictionary <int, Park> dicOfParks = new Dictionary <int, Park>();
            int j = 1;

            for (int i = 0; i < listOfParks.Count; i++)
            {
                dicOfParks[j] = listOfParks[i];
                j++;
            }
            //The count is so we can display the number needed to select that park
            int count = 1;

            foreach (var park in listOfParks)
            {
                Console.WriteLine($"{count++}) {park.Name}");
            }
            Console.WriteLine("Please Select a Park");
            int parkSelectionInt = CLIHelper.GetInteger(dicOfParks.Count);


            _UserChoicePark = dicOfParks[parkSelectionInt];
            return(_UserChoicePark);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Method to give user the option to see available sites at their selected Campground
        /// </summary>
        /// <param name="parkId"></param>
        public void CampgroundInformation(int parkId)
        {
            ParkCampgrounds(parkId);

            bool timeToExit = false;

            while (!timeToExit)
            {
                Console.WriteLine();
                Console.WriteLine("1) Search for availability & book your reservation");
                Console.WriteLine("2) Return to Previous Screen");
                Console.WriteLine();
                int command = CLIHelper.GetInteger("Press (1) to Reserve, or (2) to go back:");

                if (command == 1)
                {
                    timeToExit = true;
                    CampgroundReservation(parkId);
                }
                else if (command == 2)
                {
                    timeToExit = true;
                }
                else
                {
                    Console.WriteLine("Please enter a valid selection.");
                }
            }
        }
        private void Reservation(int campgroundId)
        {
            DateTime arrivalInput = CLIHelper.GetDateTime("What is your desired arrival date?(MM/DD/YYYY)");
            DateTime fromDate     = Convert.ToDateTime(arrivalInput);

            DateTime departureInput = CLIHelper.GetDateTime("When would you like to leave?(MM/DD/YYYY)");
            DateTime toDate         = Convert.ToDateTime(departureInput);

            Console.WriteLine("Showing available sites ");

            SiteSqlDAL  sal          = new SiteSqlDAL(connectionString);
            List <Site> allCampSites = sal.CampsiteAvailability(campgroundId, fromDate, toDate);

            if (allCampSites.Count() <= 0)
            {
                Console.WriteLine("No available camp sites! Please make a new selection.");
                return;
            }
            else
            {
                foreach (Site s in allCampSites)
                {
                    Console.WriteLine();
                    Console.WriteLine("SiteId " + s.SiteID);
                    Console.WriteLine("Campground_Id " + s.CampgroundID);
                    Console.WriteLine("SiteNumber " + s.SiteNumber);
                    Console.WriteLine("MaxOccupancy " + s.MaxOccupancy);
                    Console.WriteLine("Handicap Accessible " + s.Accessible);
                    Console.WriteLine("MaxRvLength " + s.MaxRvLength);
                    Console.WriteLine("Utilities are available " + s.Utilities);
                }

                ReservationSqlDAL ral = new ReservationSqlDAL(connectionString);

                campgroundPrice = (ral.CostOfCampground(campgroundId) * (toDate.DayOfYear - fromDate.DayOfYear));

                Console.WriteLine("The total fee for these sites are: " + campgroundPrice.ToString("C"));
                Console.WriteLine();

                int campSiteInput = CLIHelper.GetInteger("What Camp site are you booking for?");
                Console.WriteLine();

                string nameInput = CLIHelper.GetString("What name should the reservation be under?");
                Console.WriteLine();

                DateTime createDate = DateTime.Now;
                int      wasReservationSuccessful = ral.MakeReservations(campSiteInput, nameInput, fromDate, toDate, createDate);

                if (wasReservationSuccessful > 0)
                {
                    Console.WriteLine("Success!");

                    Console.WriteLine("Here is your conformation ID: " + wasReservationSuccessful);
                }
                else
                {
                    Console.WriteLine("Sorry but that site is alreaday booked. Please try again.");
                }
            }
        }
        private void ViewParkDetails()
        {
            int parkToView = CLIHelper.GetInteger("What park would you like to view?");

            Console.WriteLine();
            NationalParkDAL npDAL = new NationalParkDAL(DatabaseConnection);

            Park p = npDAL.GetParkInfo(parkToView);


            if (p != null)
            {
                Console.WriteLine("Park ID: " + p.Id);
                Console.WriteLine("Park Name: " + p.name);
                Console.WriteLine("Location: " + p.location);
                Console.WriteLine("Established: " + p.establishdate);
                Console.WriteLine("Area: " + p.area);
                Console.WriteLine("Visitors " + p.visitors);
                Console.WriteLine(p.description);

                ParkSubmenu(p.Id);
            }
            else
            {
                Console.WriteLine("NO RESULTS IN PARKLIST");
            }
        }
Ejemplo n.º 9
0
        public void ParkCampgroundScreen(Park currentWorkingPark)
        {
            DisplayCampgrounds(currentWorkingPark);

            while (true)
            {
                string selectionMenu = "\nSelect a Command\n----------------\n1) Search for available reservation\n2) Return to previous screen\n";

                string selectionPrompt = "Selection:";

                string validSelectionError = "Please enter a valid number from the menu. Press Enter to try again.";

                int command;

                Console.WriteLine(selectionMenu);
                command = CLIHelper.GetInteger(selectionPrompt);

                switch (command)
                {
                case (1):
                    CampgroundReservationScreen(currentWorkingPark);
                    break;

                case (2):
                    return;

                default:
                    Console.WriteLine(validSelectionError);
                    Console.ReadLine();
                    break;
                }
            }
        }
        private void BookReservation()
        {
            int tempSiteId = CLIHelper.GetInteger("Which site should be reserved (enter C to cancel and go back to park listing)? __");

            string         tempResName     = CLIHelper.GetString("What name should the reservation be made under? __");
            ReservationDAL dal             = new ReservationDAL(DatabaseConnection);
            Reservation    bookReservation = new Reservation
            {
                CampId   = tempCampId,
                SiteId   = tempSiteId,
                Name     = tempResName,
                FromDate = arriveDate,
                ToDate   = departDate
            };

            Console.WriteLine();
            int ReservationId = dal.BookReservation(bookReservation);

            if (ReservationId > 0)
            {
                Console.WriteLine("Your reservation confirmation number is: " + ReservationId);
                Console.WriteLine("Thank you for booking! Please press enter to return to the Parks Menu.");
                Console.ReadLine();
                Console.Clear();
                DisplayParks();
            }
            else
            {
                Console.WriteLine("**** Reservation Could Not Be Booked ****");
            }
        }
        private void ChooseDisplayParkInfo()
        {  //this shows park information based on choice
            tempParkId = CLIHelper.GetInteger("Please enter in the Park ID for more information:");
            ParkDAL dal = new ParkDAL(DatabaseConnection);

            IList <Park> parks = dal.DisplayParkInfo(tempParkId);

            Console.WriteLine("Park Information:");
            Console.WriteLine();

            if (parks.Count > 0)
            {
                foreach (Park park in parks)
                {
                    Console.WriteLine(park.Name.ToString() + Environment.NewLine + "Location: " + park.Location + Environment.NewLine + "Established: " + park.EstablishDate.ToShortDateString() + Environment.NewLine + "Area: " + (park.Area.ToString("N0")) + " sq km" + Environment.NewLine + "Annual Vistors: " + park.Visitors.ToString("N0"));
                    Console.WriteLine();
                    Console.WriteLine(park.Description);
                    Console.WriteLine();
                }
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
            }
            Console.WriteLine();
            DisplayParkOptions();
        }
Ejemplo n.º 12
0
        private void FindAvailableCampSites()
        {
            int campground_id = CLIHelper.GetInteger("Please Select Campground ID");

            Console.WriteLine();
            DateTime startDate = CLIHelper.GetDateTime("Please Select Start of Stay (yyyy-mm-dd)");

            Console.WriteLine();
            DateTime endDate = CLIHelper.GetDateTime("Please Select Date of Depature (yyyy-mm-dd)");

            SiteDal     dal = new SiteDal(connectionString);
            List <Site> sites;

            bool avail = dal.IsSiteAvailable(campground_id, startDate, endDate);

            if (!avail)
            {
                Tools.ColorfulWriteLine("No availablity please try different dates or Campground", ConsoleColor.Red);
            }
            else if (avail)
            {
                sites = dal.GetTop5(campground_id, startDate, endDate);
                foreach (Site s in sites)
                {
                    Console.WriteLine();
                    Tools.ColorfulWriteLine($"National Site ID".PadRight(20) + "Campground Site Number".PadRight(30) + "Max Occupancy".PadRight(25) + "Total Days".PadRight(20) + "Total Cost", ConsoleColor.Yellow);
                    Console.WriteLine($"{s.site_id}".PadRight(20) + $"{s.site_number}".PadRight(30) + $"{s.max_occupancy}".PadRight(30) + $"{s.totalDays}".PadRight(20) + $"${s.totalCost}");
                }
            }
        }
        public void PrintMenu()
        {
            bool exit = false;

            while (!exit)
            {
                Console.Clear();
                PrintHeader();
                Console.WriteLine();
                Console.WriteLine("Select a park for more information or select '0' to quit.");
                DisplayParks();
                Console.WriteLine("0) Quit");
                Console.WriteLine();
                int userInput = CLIHelper.GetInteger("Enter your selection: ");

                if (userInput == 0)
                {
                    exit = true;
                }
                else
                {
                    if (userInput > 0 && userInput <= _parks.Count)
                    {
                        DisplayParkMenu(_parks[userInput]);
                    }
                    else
                    {
                        Console.WriteLine("Please choose a valid option.");
                        Console.ReadKey();
                        //WriteLine "Press any key to continue" OR Bool (Do we want to display error message?)
                    }
                }
            }
        }
        private void DisplayParkMenu(Park park)
        {
            bool exit = false;

            while (!exit)
            {
                Console.Clear();
                DisplayParkInformation(park);
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("Choose an option:");
                Console.WriteLine("1) View Campgrounds");
                Console.WriteLine("2) Return to Main Menu");

                Console.WriteLine();
                int userSel = CLIHelper.GetInteger("Enter your selection: ", true);

                //char userSel = Console.ReadKey().KeyChar; //use CLI Helper

                if (userSel == 1)
                {
                    ParkCampgroundMenu(park);
                }

                else if (userSel == 2)
                {
                    exit = true;
                }
                else
                {
                    Console.WriteLine("Please choose a valid option.");
                    Console.ReadKey();
                }
            }
        }
Ejemplo n.º 15
0
        private void GetAllCampgrounds()
        {
            ParksDAL    pdal  = new ParksDAL(DatabaseConnection);
            List <Park> parks = pdal.GetAllParks();

            if (parks.Count > 0)
            {
                foreach (Park park in parks)
                {
                    Console.WriteLine("(" + park.Park_id + ") " + park.Name);
                    Console.WriteLine();
                }

                CampgroundDAL cdal   = new CampgroundDAL(DatabaseConnection);
                int           parkId = CLIHelper.GetInteger("Please select a Park Id : ");
                Console.WriteLine();
                List <Campground> campground = cdal.GetAllCampgrounds(parkId);

                foreach (Campground camp in campground)
                {
                    Console.WriteLine("(" + camp.CampgroundId + ") " + camp.Name.PadRight(30) + "Opening Month " + months[camp.OpenFromMM].ToString().PadRight(10) + "Closing Month " + months[camp.OpenToMM].ToString().PadRight(10) + "Daily Fee " + camp.DailyFee.ToString("c"));
                    Console.WriteLine();
                }
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
            }

            Console.ReadLine();
        }
        }//DisplayParkInformationList

        private void ParkCampgroundsMenu(int park_Id)
        {
            bool returnToPreviousMenu = false;

            while (returnToPreviousMenu == false)
            {
                PrintHeader("Park Campgrounds");
                string parkName = parkNameDisplay(park_Id);
                Console.WriteLine($"{parkName} National Park Campgrounds\n");

                ParkCampgroundsList(park_Id);

                const int searchForAvailableReservations = 1;
                const int returnToPrevious = 2;

                Console.WriteLine("\nOptions");
                FlowerLine();
                Console.WriteLine("1) Search for Available Reservation");
                Console.WriteLine("2) Return to Previous Screen");
                FlowerLine();

                int viewCampgroundSelection = CLIHelper.GetInteger("Select an option:");
                if (viewCampgroundSelection == searchForAvailableReservations)
                {
                    CampgroundReservationSearchMenu(park_Id);
                }

                if (viewCampgroundSelection == returnToPrevious)
                {
                    returnToPreviousMenu = true;
                    break;
                }
            }
        }//ParkCampgroundsMenu
Ejemplo n.º 17
0
        public void ParkInformationMenu(Park park)
        {
            bool timeToExit = false;

            while (!timeToExit)
            {
                PrintParkInformation(park);
                int option = CLIHelper.GetInteger("Make your Selection from the above choice:");

                if (option < 1 || option > 2)
                {
                    Console.WriteLine("Please enter a valid option.");
                }
                else if (option == 1)
                {
                    CampgroundInformation(park.ParkId);
                }
                else if (option == 2)
                {
                    timeToExit = true;
                }
                else
                {
                    Console.WriteLine("Please enter a valid option.");
                }
            }
        }
        }//noSitesAvaialable

        void MakeReservationMenu(int park_Id, DateTime from_date, DateTime to_date, List <Site> reservationsAvailable)

        {
            bool returnToPreviousMenu = false;

            while (returnToPreviousMenu == false)
            {
                int site_selection = CLIHelper.GetInteger("Which site should be reserved(enter 0 to cancel)?");

                if (site_selection == 0)
                {
                    returnToPreviousMenu = true;
                }
                else if (!reservationsAvailable.Any(site => site.Site_Number == site_selection))
                {
                    WarningMessageFormat("This site is not available");
                    Console.ReadLine();
                }
                else
                {
                    //look up site id from avaialbe sites list using site Number.  pull site id property for reservation information.
                    Site selectedSite = (reservationsAvailable.Find(site => site.Site_Number == site_selection));

                    string         name           = CLIHelper.GetString("What name should the reservation be made under?");
                    ReservationDAL reservationDal = new ReservationDAL(DatabaseConnection);
                    int            reservation_id = reservationDal.BookReservation(selectedSite.Site_Id, name, from_date, to_date);
                    FlowerLine();
                    string confirmationMessage = ($"The reservation has been made and the confirmation id is {reservation_id}");
                    confirmationMessage += $"\nYou have booked Site No. {selectedSite.Site_Number} for {from_date.ToString("yyyy/MM/dd")} to {to_date.ToString("yyyy/MM/dd")}. Enjoy your stay!";
                    ConfirmationMessageFormat(confirmationMessage);
                    Console.ReadLine();
                    break;
                }
            }
        } //MakeReservationMenu
Ejemplo n.º 19
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.");
                }
            }
        }
        public void Run()
        {
            Header();

            while (true)
            {
                Console.WriteLine();
                Console.WriteLine("WELCOME TO THE NATIONAL PARK REGISTRATION");
                Console.WriteLine();
                Console.WriteLine("1 -- Show me all National Parks with their campgrounds.");
                Console.WriteLine("2 -- I don't need to see the Parks, I already know where I want to stay. Make Reservation!");

                string input = CLIHelper.GetString("Please make a selection: ");

                switch (input.ToLower())
                {
                case "1":
                    ShowAllNationalParks();
                    break;

                case "2":
                    int reservationInput = CLIHelper.GetInteger("What Park ID would you like to book for? ");
                    ShowAllCampgroundInAPark(reservationInput);
                    break;
                }
            }
        }
        private void ShowAllNationalParks()
        {
            Console.WriteLine("Showing Parks");

            ParkSqlDAL dal = new ParkSqlDAL(connectionString);

            List <Park> allParks = dal.GetAllParks();

            foreach (Park p in allParks)
            {
                Console.WriteLine();
                Console.WriteLine("Park ID: " + p.Park_id);
                Console.WriteLine("Park Name: " + p.Name);
                Console.WriteLine("Park Location:" + p.Location);
                Console.WriteLine("Date of Park Establishment: " + p.Establish_date);
                Console.WriteLine("Park Size: " + p.Area);
                Console.WriteLine("Number of vistors in Park: " + p.Vistitors);
                Console.WriteLine("Description of Park: " + p.Description);
            }

            Console.WriteLine();
            Console.WriteLine("Would you Like to see a Parks campgrounds(Y/N)?");
            string input = Console.ReadLine().ToUpper();

            if (input == "Y")
            {
                int userInputParkId = CLIHelper.GetInteger("Please enter a Park Id");

                ShowAllCampgroundInAPark(userInputParkId);
            }
            return;
        }
Ejemplo n.º 22
0
        private bool PrintMainMenu()
        {
            Console.WriteLine("Select a Park for Further Details");
            Console.WriteLine();

            IList <Park> allParks = parkDAO.GetAllParks();

            foreach (Park park in allParks)
            {
                Console.WriteLine($"{park.ParkId}) {park.Name}");
            }

            Console.WriteLine("0 - Quit");
            Console.WriteLine();


            int parkSelection = CLIHelper.GetInteger("Select park number to display more information");

            if (parkSelection == 0)
            {
                return(false);
            }
            foreach (Park park in allParks)
            {
                if (park.ParkId == parkSelection)
                {
                    PrintParkInfoMenu(park);
                    return(true);
                }
            }

            Console.WriteLine("you gave an incorrect park id");
            Console.ReadLine();
            return(true);
        }
        //Displays the campgrounds for a specific park and options to continue
        public void DisplayCampgrounds(int park_id, string park_name)
        {
            IList <Campground> campgrounds = campgroundSqlDAO.GetCampgroundsByPark(park_id);
            bool done = false;

            while (!done)
            {
                Console.Clear();
                Console.WriteLine("Park Campgrounds");
                Console.WriteLine(park_name);

                DisplayHelper.DisplayCampgrounds(campgrounds);

                int cgChoice = CLIHelper.GetInteger("\nSelect a Campground to reserve (or enter 0 to return):  ");

                if (cgChoice != 0)
                {
                    DateTime[] dateRange = CLIHelper.GetDateRange("Please enter your planned arrival date: ", "Please enter your planned departure date : ");
                    DisplayOpenSites(campgrounds[cgChoice - 1].Campground_Id, dateRange[0], dateRange[1], campgrounds[cgChoice - 1].Daily_fee);
                }
                else
                {
                    done = true;
                }
            }
        }
        private void SearchReservations(Park userParkChoice)
        {
            ViewCampgrounds(userParkChoice);
            int      userChoiceCampgroundID = CLIHelper.GetInteger("Enter the desired campground ID: ");
            DateTime userChoiceStartDate    = CLIHelper.GetDateTime("Enter the desired start date: (YYYY/MM/DD) ");
            DateTime userChoiceEndDate      = CLIHelper.GetDateTime("Enter the desired end date: (YYYY/MM/DD) ");

            ReservationSQLDAL dal            = new ReservationSQLDAL(DatabaseConnection);
            List <Site>       availableSites = dal.SearchForAvailableReservations(userChoiceCampgroundID, userChoiceStartDate, userChoiceEndDate);

            CampgroundSQLDAL cgDal            = new CampgroundSQLDAL(userChoiceCampgroundID, DatabaseConnection);
            decimal          totalCampingCost = cgDal.GetCampgroundDailyRate();
            int totalDays = Convert.ToInt32((userChoiceEndDate - userChoiceStartDate).TotalDays);

            if (availableSites.Count > 0)
            {
                Console.WriteLine("Showing First Five Available Sites:");
                Console.WriteLine("Site No.     Max Occupancy    Accessible?    Max RV Length    Utilites?   Total Cost");
                foreach (Site site in availableSites)
                {
                    Console.WriteLine("#" + site.SiteNumber + "  " + site.MaxOccupancy + "   " + site.IsAccessible + "   " + site.MaxRVLength + "   " + site.HasUtilities + "   " + (totalCampingCost * totalDays).ToString("C2"));
                }
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
            }
        }
        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);
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// SearchCampSites method calls the GetSites method from the SiteSqlDAL and pass it to a list which we then call in the if statement
        /// and if count > 0 we then print out the appropriate response and we again use the foreach loop to print out the results from the
        /// database. we also use the CLIhelper again to take in the user input.
        /// </summary>
        private void SearchCampSites()
        {
            int      campgroundId = CLIHelper.GetInteger("Which campground (enter 0 to cancel)? ");
            DateTime startDate    = CLIHelper.GetDateTime("What is the arrival date? (YYYY/MM/DD): ");
            DateTime endDate      = CLIHelper.GetDateTime("What is the departure date? (YYYY/MM/DD): ");

            //double totalDays = (endDate - startDate).TotalDays;

            SiteSqlDAL  dal      = new SiteSqlDAL(DatabaseConnection);
            List <Site> allSites = dal.GetSites(campgroundId, startDate, endDate);

            if (allSites.Count > 0)
            {
                Console.WriteLine();
                Console.WriteLine("Site Number".PadRight(14) + "Max Occupancy".PadRight(15) + "Accessible".PadRight(15) + "Max RV Length".PadRight(17) + "Utilities".PadRight(16) + "Cost".PadRight(15));
                Console.WriteLine();

                allSites.ForEach(theseSites =>
                {
                    Console.WriteLine(theseSites);
                });
            }
            else
            {
                Console.WriteLine("There was an error with your inputs...");
            }
        }
        /// <summary>
        /// Books a site reservation
        /// </summary>
        /// <param name="sites">List of available sites</param>
        /// <param name="arrivalDate">Arrival date for the reservation</param>
        /// <param name="departureDate">Departure date for the reservation</param>
        private void BookReservation(IList <Site> sites, DateTime arrivalDate, DateTime departureDate)
        {
            int siteIndex = -1;

            do
            {
                int siteNumber = CLIHelper.GetInteger("Which site should be reserved (enter 0 to cancel)? ");

                if (siteNumber == 0)
                {
                    Console.Clear();
                    return;
                }

                siteIndex = sites.IndexOf(sites.Where(x => x.SiteNumber == siteNumber).FirstOrDefault());
            } while (siteIndex < 0);

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

            int reservationId = reservationDAO.AddReservation(sites[siteIndex].SiteId, name, arrivalDate, departureDate);

            Console.WriteLine("".PadRight(lineWidth, lineChar));

            if (reservationId > 0)
            {
                Console.WriteLine("The reservation has been made and the confirmation id is {" + reservationId + "}.\n");
            }
            else
            {
                Console.WriteLine("An error occurred making the reservation.");
            }

            Console.WriteLine("Press any key to return to the previous menu");
            Console.ReadKey();
        }
Ejemplo n.º 28
0
        /// <summary>
        /// In the makeAreservation method we again use the cli helper to take in user input.
        /// It calls the MakeReservation method from the ReservationSqlDAL class and uses it in a list
        /// We created variables of type string in and dateTime to store the user input then we called the reservation class
        /// from the models folder and assigned the user input to the variables in the reservation class which are get; set; properties
        /// We then call the list in a  if statement again and if count of items in list is > 0 we then print out the response with the
        /// reservation id confirming their reservation has been created.
        /// </summary>
        private void MakeAreservation()
        {
            string   name      = CLIHelper.GetString("Please enter the reservation name: ");
            int      site_id   = CLIHelper.GetInteger("Please enter the site number: ");
            DateTime startDate = CLIHelper.GetDateTime("Please enter the arrival date(YYYY/MM/DD): ");
            DateTime endDate   = CLIHelper.GetDateTime("Please enter the departure date(YYYY/MM/DD): ");


            Reservation newRes = new Reservation()
            {
                Name       = name,
                SiteID     = site_id,
                FromDate   = startDate,
                ToDate     = endDate,
                CreateDate = DateTime.Now
            };

            ReservationSqlDAL  dal     = new ReservationSqlDAL(DatabaseConnection);
            List <Reservation> confirm = dal.MakeReservation(newRes);

            if (confirm.Count > 0)
            {
                Console.WriteLine();
                Console.WriteLine("The reservation has been made and the confirmation ID is: " + confirm[0].ReservationId);
            }
            else
            {
                Console.WriteLine("DID NOT MAKE RESERVATION");
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Display the list of parks
        /// </summary>
        /// <returns>The park id selected by user</returns>
        private int DisplayAllParks()
        {
            int parkSelection = 0;

            while (true)
            {
                ParkSqlDAL   dal   = new ParkSqlDAL(DatabaseConnection);
                IList <Park> parks = dal.GetParks();


                if (parks.Count > 0)
                {
                    Console.WriteLine("Please select the national park that you wish to visit.");
                    foreach (Park park in parks)
                    {
                        Console.WriteLine(park.ParkId.ToString().PadRight(10) + park.Name.PadRight(40));
                    }
                    Console.Write(">>  ");
                    parkSelection = CLIHelper.GetInteger(Console.ReadLine());
                    if (parkSelection <= parks.Count && parkSelection > 0)
                    {
                        break;
                    }
                    Console.Clear();
                }
                else
                {
                    Console.WriteLine("**** SOLD TO PRIVATE CORPORATION-TEDDY ROOSEVELT SPINNING IN GRAVE ****");
                }
            }
            return(parkSelection);
        }
        private int ChooseCampground(Park selectedPark, List <Campground> campgroundsInPark, int dateRangeSelected)
        {
            //run ViewCampgrounds() then ask for user input

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("SEARCH FOR CAMPSITE RESERVATION");
            campgroundsInPark = ViewCampgrounds(selectedPark, campgroundsInPark);
            int inputCampgroundNumber = CLIHelper.GetInteger("Which campground (enter 0 to cancel)?");

            Console.WriteLine();

            //input of zero returns to ViewParksMenu()
            //invalid number exits method and calls it again (while dateRangeSelected == -1)
            //valid number calls next method

            if (inputCampgroundNumber == 0)
            {
                Console.WriteLine();
                dateRangeSelected = 0;
            }
            else if (inputCampgroundNumber > campgroundsInPark.Count)
            {
                Console.WriteLine("Invalid Input. Please select a campground number from the list:");
            }
            else
            {
                while (dateRangeSelected == -1)
                {
                    dateRangeSelected = SearchForAvailableSites(inputCampgroundNumber, campgroundsInPark);
                }
            }
            return(dateRangeSelected);
        }