public void TrueSearchReservationsTest()
        {
            ReservationSQLDAL reservation = new ReservationSQLDAL(connectionString);
            int trueResult = reservation.BookReservation(1, 1, new System.DateTime(1980, 7, 4), new System.DateTime(1980, 7, 11), "Terranova");

            Assert.IsTrue(trueResult > 0);
        }
        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 ****");
            }
        }
Esempio n. 3
0
        public void GetAllReservations()
        {
            List <Reservation> myReservationsTest = new List <Reservation>();

            ReservationSQLDAL mySQLTest = new ReservationSQLDAL(connectionString);

            myReservationsTest = mySQLTest.GetAllReservations();
        }
        public void SearchForAvailableSitesTest()
        {
            ReservationSQLDAL dal = new ReservationSQLDAL(connectionString);

            List <Site> validSites = dal.SearchForAvailableReservations(campgroundID, start, end);

            Assert.IsNotNull(validSites);
            Assert.IsTrue(validSites.Count > 0);
        }
Esempio n. 5
0
        private void GetReservations()
        {
            ReservationSQLDAL dal = new ReservationSQLDAL(connectionString);

            List <Reservation> reservations = dal.GetAllReservations();

            Console.WriteLine();

            foreach (var reservation in reservations)
            {
                Console.WriteLine();
                Console.WriteLine(reservation);
            }
        }
Esempio n. 6
0
        public void AddNewReservation()
        {
            Reservation myReservationTest = new Reservation();

            myReservationTest.CampgroundId = 1;
            myReservationTest.FromDate     = new DateTime(2017, 02, 20);
            myReservationTest.ToDate       = new DateTime(2017, 03, 01);
            myReservationTest.SiteId       = 9;
            myReservationTest.Name         = "Test Johnson";

            ReservationSQLDAL mySQLTest = new ReservationSQLDAL(connectionString);

            myReservationTest.ReservationId = mySQLTest.AddNewReservation(myReservationTest);
        }
Esempio n. 7
0
        public void DisplayCampsiteAndReservations(List <Campsite> campsites)
        {
            foreach (var campsite in campsites)
            {
                Console.WriteLine(campsite);
            }

            Console.WriteLine();
            Console.WriteLine("Do you want to make a reservation?");
            string userChoice = Console.ReadLine().ToUpper();

            if (userChoice == "Y")
            {
                ReservationSQLDAL resDal = new ReservationSQLDAL(connectionString);

                Console.WriteLine("Please Enter the Campsite Id...");
                newReservation.SiteId = int.Parse(Console.ReadLine());

                Console.WriteLine("What is the last name for the reservation?");
                newReservation.Name = Console.ReadLine();

                if (newReservation.ToDate == DateTime.MinValue)
                {
                    AskForTravelDates();
                }

                resDal.AddNewReservation(newReservation);

                if (newReservation.ReservationId > 0)
                {
                    Console.WriteLine(newReservation);
                }
                else
                {
                    Console.WriteLine("Invalid Date Range.");
                }
            }
            else if (userChoice == "N")
            {
                //send them back to the main menu
            }
            else
            {
                Console.WriteLine("Invalid input.");
            }
        }
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.");
                }
            }
        }