예제 #1
0
        public void GetAvailableCampgroundsTest()
        {
            CampgroundSQLDAL campground = new CampgroundSQLDAL(connectionString);
            bool             result     = CampgroundSQLDAL.GetAvailableCampgrounds(1, maxID);

            Assert.IsTrue(result);
        }
예제 #2
0
        public void GetCampgroundsTest()
        {
            CampgroundSQLDAL  campground  = new CampgroundSQLDAL(connectionString);
            List <Campground> campgrounds = CampgroundSQLDAL.GetAllCampgrounds(1);

            Assert.IsNotNull(campgrounds);
        }
        private void ViewCampgrounds(Park userParkChoice)
        {
            CampgroundSQLDAL         dal            = new CampgroundSQLDAL(DatabaseConnection, userParkChoice.ParkID);
            List <Campground>        allCampgrounds = dal.GetCampgrounds();
            Dictionary <int, string> allMonths      = new Dictionary <int, string>
            {
                { 1, "January" },
                { 2, "February" },
                { 3, "March" },
                { 4, "April" },
                { 5, "May" },
                { 6, "June" },
                { 7, "July" },
                { 8, "August" },
                { 9, "September" },
                { 10, "October" },
                { 11, "November" },
                { 12, "December" }
            };

            Console.WriteLine("Showing all campgrounds for " + userParkChoice.ToString() + "\n");
            Console.WriteLine("Campground ID    Name    Open    Close   Daily Fee");

            foreach (Campground camp in allCampgrounds)
            {
                Console.WriteLine("#" + camp.CampgroundID + camp.CampgroundName + allMonths[camp.OpenFromMonth] + allMonths[camp.OpenToMonth] + camp.DailyFee.ToString("C2"));
            }
        }
        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 ****");
            }
        }
예제 #5
0
        public void TestGetAllCampgroundsParkIDDate()
        {
            //Arrange
            CampgroundSQLDAL campgroundDAL = new CampgroundSQLDAL(connectionString);

            //Act
            int campgroundCount = campgroundDAL.GetAllCampgroundsParkID(1).Count;

            //Assert
            Assert.IsNotNull(campgroundCount);
            Assert.AreEqual(numberOfAvailableCampgrounds, campgroundCount);
        }
예제 #6
0
        public void SearchForReservation(int parkID)
        {
            bool done = false;

            while (!done)
            {
                Reservation reservation = new Reservation();

                Console.WriteLine();
                Console.WriteLine("Search for Campground Reservation");
                PrintCampgrounds(parkID);
                Console.WriteLine();
                Console.WriteLine("Which campground? (enter 0 to cancel)");
                int campgroundID = int.Parse(Console.ReadLine());
                if (campgroundID == 0)
                {
                    done = true;
                    break;
                }
                else if (!(CampgroundSQLDAL.GetAvailableCampgrounds(parkID, campgroundID)))
                {
                    Console.WriteLine();
                    Console.WriteLine("Not a valid selection. Press enter to continue.");
                    Console.WriteLine();
                    Console.ReadLine();
                    continue;
                }
                Console.WriteLine("What is the arrival date? (MM/DD/YYYY)");
                DateTime arrivalDate = DateTime.Parse(Console.ReadLine());
                Console.WriteLine("What is the departure date? (MM/DD/YYYY)");
                DateTime departureDate = DateTime.Parse(Console.ReadLine());

                if (arrivalDate > departureDate)
                {
                    Console.WriteLine("Invalid date selection. Press enter to continue.");
                    Console.WriteLine();
                    Console.ReadLine();
                    continue;
                }

                PrintAvailableCampsites(campgroundID, arrivalDate, departureDate);
            }
        }
예제 #7
0
        public void DisplayCampgrounds(bool datesAreGiven)
        {
            CampgroundSQLDAL  dal         = new CampgroundSQLDAL(connectionString);
            List <Campground> campgrounds = new List <Campground>();

            if (datesAreGiven)
            {
                campgrounds = dal.GetAllCampgroundsParkIDDate(newCampsite.ParkId, newReservation.FromDate, newReservation.ToDate);
            }
            else
            {
                campgrounds = dal.GetAllCampgroundsParkID(newCampsite.ParkId);
            }

            foreach (var campground in campgrounds)
            {
                Console.WriteLine(campground.CampID + "- " + campground.Name);
            }
        }
예제 #8
0
        public void PrintCampgrounds(int parkID)
        {
            CampgroundSQLDAL  dal         = new CampgroundSQLDAL(DatabaseConnection);
            List <Campground> campgrounds = CampgroundSQLDAL.GetAllCampgrounds(parkID);

            if (campgrounds.Count > 0)
            {
                Console.WriteLine();
                Console.WriteLine("Name".PadLeft(11).PadRight(43) + "Open".PadRight(15) + "Close".PadRight(15) + "Fee");
                Console.WriteLine(new String('=', 79));
                foreach (Campground campground in campgrounds)
                {
                    Console.WriteLine($"#{campground.CampgroundID.ToString().PadRight(5)} {campground.CampgroundName.ToString().PadRight(35)} {CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(campground.OpenMonth).PadRight(14)} {CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(campground.CloseMonth).PadRight(14)} {campground.DailyFee.ToString("C2")}");
                }
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine("NO RESULTS");
                Console.WriteLine();
            }
        }