Esempio n. 1
0
        public void PrintAvailableCampsites(int campgroundID, DateTime arrivalDate, DateTime departureDate)
        {
            CampsiteSQLDAL dal = new CampsiteSQLDAL(DatabaseConnection);

            List <Campsite> campsites = CampsiteSQLDAL.SearchCampsites(campgroundID, arrivalDate, departureDate);

            if (campsites.Count > 0)
            {
                Console.WriteLine();
                Console.WriteLine("Results Matching Your Search Criteria");
                Console.WriteLine();
                Console.WriteLine("Site No.".PadRight(10) + "Max Occupancy".PadRight(15) + "Accessible?".PadRight(15) + "Max RV Length".PadRight(15) + "Utility".PadRight(15) + "Cost");
                Console.WriteLine(new String('=', 77));
                foreach (Campsite campsite in campsites)
                {
                    decimal totalFee = CLIHelper.GetTotalFee(campsite.DailyFee, arrivalDate, departureDate);
                    Console.Write(campsite.SiteNumber.ToString().PadRight(10));
                    Console.Write(campsite.MaxOccupancy.ToString().PadRight(15));
                    Console.Write((campsite.Accessible == true ? "YES" : "NO").PadRight(15));
                    Console.Write((campsite.MaxRVLength != 0 ? campsite.MaxRVLength.ToString() : "N/A").PadRight(15));
                    Console.Write((campsite.Utilities == true ? "YES" : "N/A").PadRight(15));
                    Console.WriteLine(totalFee.ToString("C2"));
                }
                Console.WriteLine();

                BookingMenu(campgroundID, arrivalDate, departureDate);
            }
            else
            {
                Console.WriteLine("No available sites. Would you like to enter an alternate date range?");
                Console.WriteLine();
            }
        }
Esempio n. 2
0
        public void GetCampsiteTest()
        {
            CampsiteSQLDAL  reservation = new CampsiteSQLDAL(connectionString);
            List <Campsite> campsites   = CampsiteSQLDAL.SearchCampsites(1, new System.DateTime(2019, 01, 01), new System.DateTime(2019, 02, 01));

            Assert.IsNotNull(campsites);
        }
Esempio n. 3
0
        public void GetAvailableCampsitesTest()
        {
            CampsiteSQLDAL campsite = new CampsiteSQLDAL(connectionString);
            bool           result   = CampsiteSQLDAL.GetAvailableCampsites(1, new System.DateTime(1970, 1, 1), new System.DateTime(1970, 2, 1), 1);

            Assert.IsTrue(result);
        }
Esempio n. 4
0
        public void OfferDateRangeByParkID()
        {
            CampsiteSQLDAL  dal       = new CampsiteSQLDAL(connectionString, false);
            List <Campsite> campsites = new List <Campsite>();

            Console.WriteLine("Do you want to choose a date range? (Y/N)");
            string dateChoice = Console.ReadLine().ToUpper();

            if (dateChoice == "N")
            {
                campsites = dal.GetCampsitesByParkId(newCampsite.ParkId);
                DisplayCampsiteAndReservations(campsites);
            }
            else if (dateChoice == "Y")
            {
                AskForTravelDates();

                campsites = dal.GetCampsitesByParkIdAndAvailableDates(newCampsite.ParkId, newReservation.FromDate, newReservation.ToDate);
                DisplayCampsiteAndReservations(campsites);
            }
            else
            {
                Console.WriteLine("Invalid Input...");
            }
        }
Esempio n. 5
0
        public void DisplayParkforParkIDAndDate()
        {
            GetAllParksShortDisplay();

            Console.WriteLine();
            Console.WriteLine("Please Enter the Park Id...");
            newCampsite.ParkId = int.Parse(Console.ReadLine());

            Console.WriteLine("Do you wish to search the whole (p)ark or a specific (c)ampground? ");
            string userChoice = Console.ReadLine();

            CampsiteSQLDAL  dal       = new CampsiteSQLDAL(connectionString, false);
            List <Campsite> campsites = new List <Campsite>();

            if (userChoice == "p")
            {
                campsites = dal.GetCampsitesByParkIdAndAvailableDates(newCampsite.ParkId, newReservation.FromDate, newReservation.ToDate);
                DisplayCampsiteAndReservations(campsites);
            }
            else if (userChoice == "c")
            {
                DisplayCampgrounds(true);

                Console.WriteLine("Please enter a choice for campground...");

                newCampsite.CampgroundId = int.Parse(Console.ReadLine());
                campsites = dal.GetCampsitesByParkIdAndCampgroundId(newCampsite.ParkId, newCampsite.CampgroundId);

                DisplayCampsiteAndReservations(campsites);
            }
            else
            {
                Console.WriteLine("Invalid Input. Please Start Again...");
            }
        }
Esempio n. 6
0
        public void GetCampsitesByParkAndCampground()
        {
            List <Campsite> myListOfReturnedCampsites = new List <Campsite>();

            CampsiteSQLDAL mySQLTest = new CampsiteSQLDAL(connectionString, false);

            myListOfReturnedCampsites = mySQLTest.GetCampsitesByParkIdAndCampgroundId(1, 3);
        }
Esempio n. 7
0
        private void DisplayParkforParkID()
        {
            GetAllParksShortDisplay();

            Console.WriteLine();
            Console.WriteLine("Please Enter the Park Id...");
            newCampsite.ParkId = int.Parse(Console.ReadLine());

            Console.WriteLine("Do you wish to search the whole (p)ark or a specific (c)ampground? ");
            string userChoice = Console.ReadLine();

            CampsiteSQLDAL  dal       = new CampsiteSQLDAL(connectionString, false);
            List <Campsite> campsites = new List <Campsite>();

            if (userChoice == "p")
            {
                OfferDateRangeByParkID();
            }
            else if (userChoice == "c")
            {
                DisplayCampgrounds(false);

                Console.WriteLine("Please enter a choice for campground...");

                newCampsite.CampgroundId = int.Parse(Console.ReadLine());

                Console.WriteLine("Do you want to choose a date range? (Y/N)");
                string dateChoice = Console.ReadLine().ToUpper();

                if (dateChoice == "N")
                {
                    campsites = dal.GetCampsitesByParkIdAndCampgroundId(newCampsite.ParkId, newCampsite.CampgroundId);
                }
                else if (dateChoice == "Y")
                {
                    AskForTravelDates();

                    campsites = dal.GetCampsitesByParkCampgroundAndAvailableDates(newCampsite.ParkId, newCampsite.CampgroundId, newReservation.FromDate, newReservation.ToDate);
                }

                DisplayCampsiteAndReservations(campsites);
            }
            else
            {
                Console.WriteLine("Invalid Input. Please Start Again...");
            }
        }
Esempio n. 8
0
        public void BookingMenu(int campgroundID, DateTime arrivalDate, DateTime departureDate)
        {
            int reservationID     = 0;
            ReservationSQLDAL dal = new ReservationSQLDAL(DatabaseConnection);
            bool done             = false;

            while (!done)
            {
                Console.WriteLine();
                Console.WriteLine("Which Site Should be Reserved? (0 To Cancel)");
                int siteNumber = int.Parse(Console.ReadLine());
                if (siteNumber == 0)
                {
                    done = true;
                    break;
                }
                else if (!(CampsiteSQLDAL.GetAvailableCampsites(campgroundID, arrivalDate, departureDate, siteNumber)))
                {
                    Console.WriteLine();
                    Console.WriteLine("Not a valid selection. Press enter to continue.");
                    Console.WriteLine();
                    Console.ReadLine();
                    continue;
                }

                Console.WriteLine("What Name Should the Reservation be Made Under?");
                string reservationName = Console.ReadLine();

                reservationID = dal.BookReservation(siteNumber, campgroundID, arrivalDate, departureDate, reservationName);

                if (reservationID > 0)
                {
                    Console.WriteLine();
                    Console.WriteLine($"The reservation has been made and the confirmation id is {reservationID}. Press enter to continue.");
                    Console.ReadLine();
                    done = true;
                }
                else
                {
                    Console.WriteLine("Error making reservation. Please try again.");
                }
            }
        }
Esempio n. 9
0
        public void GetReservationDates()
        {
            CampsiteSQLDAL  dal       = new CampsiteSQLDAL(connectionString, false);
            List <Campsite> campsites = new List <Campsite>();

            AskForTravelDates();

            Console.WriteLine("Do you wish to display campsites by (a)ll parks or a (s)pecific park?");
            string userChoice = Console.ReadLine().ToUpper();

            if (userChoice == "A")
            {
                campsites = dal.GetCampsitesByAvailableDates(newReservation.FromDate, newReservation.ToDate);
                DisplayCampsiteAndReservations(campsites);
            }
            else if (userChoice == "S")
            {
                DisplayParkforParkIDAndDate();
            }
            else
            {
                Console.WriteLine("Invalid Input. Please Start Again...");
            }
        }