private void ViewCampgrounds(Park selectedPark)
        {
            CampgroundSqlDAL  campgroundDAL = new CampgroundSqlDAL(connectionString);
            List <Campground> campgrounds   = campgroundDAL.GetCampgrounds(selectedPark);

            Console.WriteLine($"#:".PadRight(8) + "Campground Name".PadRight(41) + "Open From:".PadRight(16) + "Open To:".PadRight(16) + "Daily Fee".PadRight(5));
            foreach (Campground campground in campgrounds)
            {
                Console.WriteLine(campground.ToString());
            }
            Console.WriteLine("Select A Command");
            Console.WriteLine("1) Search for Available Reservation");
            Console.WriteLine("2) Return To Previous Screen");

            string campgroundMenuInput = Console.ReadLine();

            switch (campgroundMenuInput)
            {
            case "1":
                input = "4";

                break;

            case "2":
                input = "2";

                break;

            default:
                Console.WriteLine("Please select a valid input. Press enter to try again.");
                Console.ReadLine();

                break;
            }
        }
Exemplo n.º 2
0
        private IList <Campground> GetCampgrounds(int parkId)
        {
            ICampgroundDAL     campdal     = new CampgroundSqlDAL(DatabaseConnectionString.DatabaseString);
            IList <Campground> campgrounds = campdal.GetCampgrounds(parkId);

            return(campgrounds);
        }
Exemplo n.º 3
0
        public void GetCampgroundsTest()
        {
            CampgroundSqlDAL  campgroundSqlDAL = new CampgroundSqlDAL();
            string            name             = "Acadia";
            List <Campground> test             = campgroundSqlDAL.GetCampgrounds(name);

            Assert.IsNotNull(test);
        }
        public void GetCampgroundsTest()
        {
            CampgroundSqlDAL dal = new CampgroundSqlDAL(ConnectionString);

            var campground = dal.GetCampgrounds(1);

            Assert.AreEqual(1, campground.Count);
        }
Exemplo n.º 5
0
        public void GetAllCampgroundsTest()
        {
            CampgroundSqlDAL  dal      = new CampgroundSqlDAL(connectionString);
            List <Campground> testList = dal.GetCampgrounds(1);

            Assert.AreEqual(1, testList[0].ParkId);
            Assert.AreEqual(4, testList.Count);
            Assert.IsNotNull(testList);
        }
Exemplo n.º 6
0
        private void ViewCampgrounds(Park selectedPark)
        {
            CampgroundSqlDAL  campgroundDAL = new CampgroundSqlDAL(connectionString);
            List <Campground> campgrounds   = campgroundDAL.GetCampgrounds(selectedPark);

            foreach (Campground campground in campgrounds)
            {
                Console.WriteLine(campground.ToString());
            }
        }
        public void GetCampgrounds_GetsCampgrounds()
        {
            // Arrange
            CampgroundSqlDAL CSDal = new CampgroundSqlDAL(ConnectionString);

            // Act
            IList <Campground> campgrounds = CSDal.GetCampgrounds(1);

            // Assert
            Assert.AreEqual(1, campgrounds.Count);
        }
Exemplo n.º 8
0
        public void ViewCampgroundsMenu(string park)
        {
            CampgroundSqlDAL campgroundSqlDAL = new CampgroundSqlDAL();

            List <Campground> campgrounds = campgroundSqlDAL.GetCampgrounds(park);

            Console.WriteLine();
            PrintTitleScreen(park + " Campgrounds");
            Console.WriteLine("".PadRight(4) + "Name".PadRight(32) + "Open".PadRight(9) + "Close".PadRight(11) + "Daily fee");

            for (int i = 0; i < campgrounds.Count; i++)
            {
                Console.WriteLine(i + 1 + ")".PadRight(3) +
                                  campgrounds[i].Name.PadRight(32) +
                                  ReturnMonthName(campgrounds[i].OpenMonth).PadRight(9) +
                                  ReturnMonthName(campgrounds[i].ClosingMonth).PadRight(11) +
                                  campgrounds[i].DailyFee.ToString("C2"));
            }

            int  campgroundSelection = 0;
            bool validinput          = false;

            do
            {
                Console.Write("\nWhich campground (enter 0 to cancel): ");
                string userInput = Console.ReadLine();

                if (int.TryParse(userInput, out campgroundSelection))
                {
                    if (campgroundSelection >= 0 && campgroundSelection <= campgrounds.Count)
                    {
                        validinput = true;
                    }
                }

                if (validinput == false)
                {
                    Console.WriteLine("Not a valid input. Please try again.");
                }
            } while (validinput == false);

            if (campgroundSelection == 0)
            {
                return;
            }

            else
            {
                SearchCampgroundReservations(park, campgrounds[campgroundSelection - 1].Name);
            }
        }
        public bool CampGroundReservation(int intInput)
        {
            DisplayCampgrounds(intInput);
            CampgroundSqlDAL  dal   = new CampgroundSqlDAL(connectionString);
            List <Campground> camps = dal.GetCampgrounds(intInput);

            DateTime arrivalResult   = DateTime.MinValue;
            DateTime departureResult = DateTime.MinValue;
            DateTime TodayDate       = DateTime.Today;

            Console.WriteLine();
            int campgroundID = CLIHelper.GetInteger("Which campground? (enter 0 to cancel)");

            if (campgroundID == 0)
            {
                Console.WriteLine("Hope to have you stay next time!");
                return(false);
            }
            else if (campgroundID < 0 && campgroundID > camps.Count)
            {
                Console.WriteLine("Please select valid campground");
                Console.WriteLine();
                return(true);
            }
            string arrivalDate = CLIHelper.GetString("What is the arrival date? (mm/dd/yyyy)");

            if (!DateTime.TryParse(arrivalDate, out arrivalResult) || arrivalResult < TodayDate)
            {
                Console.WriteLine("Please provide a valid date of arrival for the reservation.");
                Console.ReadLine();
                return(true);
            }
            string departureDate = CLIHelper.GetString("What is the departure date? (mm/dd/yyyy)");

            if (!DateTime.TryParse(departureDate, out departureResult) || departureResult <= arrivalResult)
            {
                Console.WriteLine("Please provide a valid date of depature for the reservation.");
                Console.ReadLine();
                return(true);
            }
            else if (departureResult < arrivalResult)
            {
                Console.WriteLine();
                Console.WriteLine("Departure date cannot be before the arrival date. Pleases try again with a valid date of departure.");
                return(true);
            }

            AvailableSitesToReserve(campgroundID, arrivalDate, departureDate);
            return(true);
        }
            public void ReturnSelectedParkCampgroundsTest()
            {
                CampgroundSqlDAL  dal      = new CampgroundSqlDAL(connectionString);
                List <Campground> testList = dal.GetCampgrounds(4);

                foreach (Campground camps in testList)
                {
                    Assert.AreEqual(2, camps.ParkId);
                    Assert.AreEqual("Devil's Garden", camps.Name);
                    Assert.AreEqual("Jan", camps.OpenMonth);
                    Assert.AreEqual("Dec", camps.CloseMonth);
                    Assert.AreEqual(25.00, camps.DailyFee);
                }
            }
            public void InsertNewCampgroundsIntoCampgroundsTest()
            {
                CampgroundSqlDAL  dal      = new CampgroundSqlDAL(connectionString);
                List <Campground> testList = dal.GetCampgrounds(8);

                foreach (Campground camps in testList)
                {
                    Assert.AreEqual(2, camps.ParkId);
                    Assert.AreEqual("test campground", camps.Name);
                    Assert.AreEqual("Feb", camps.OpenMonth);
                    Assert.AreEqual("Dec", camps.CloseMonth);
                    Assert.AreEqual(27.00, camps.DailyFee);
                }
            }
        void DisplayCampgrounds(int intInput)
        {
            CampgroundSqlDAL  dal   = new CampgroundSqlDAL(connectionString);
            List <Campground> camps = dal.GetCampgrounds(intInput);

            DateTimeFormatInfo dateTimeInfo = new DateTimeFormatInfo();

            Console.WriteLine();
            Console.WriteLine("National Park Campgrounds");
            Console.WriteLine();
            Console.WriteLine("    Name                               Open  Close  Daily Fee");

            foreach (Campground camp in camps)
            {
                Console.WriteLine("#" + camp.CampgroundId.ToString().PadRight(3) + camp.Name.ToString().PadRight(35) + dateTimeInfo.GetAbbreviatedMonthName(camp.OpenMonth).PadRight(6) + dateTimeInfo.GetAbbreviatedMonthName(camp.CloseMonth).PadRight(7) + string.Format("{0:C}", camp.DailyFee));
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// GetAllCampgrounds calls the GetCampgrounds method from the campgroundSqlDAL it creates a list and calls that list
        /// into a if statement. it uses the cli helper to take in user input like a readline would
        /// it the GetCampgrounds method takes in a parameter of type int parkID so we created myParkID
        /// which is the number the user enters and then put that into the list.
        /// If the count in the list is > 0 it prints out all the campground information to the console screen
        /// we added a console writeline for formatting purposes so the user new what each column represented.
        /// </summary>
        private void GetAllCampgrounds()
        {
            int myParkid                  = CLIHelper.GetInteger("Please enter the Park ID (1 (Acadia) , 2 (Arches) or 3 (Cuyahoga National Valley Park): ");
            CampgroundSqlDAL  dal         = new CampgroundSqlDAL(DatabaseConnection);
            List <Campground> campgrounds = dal.GetCampgrounds(myParkid);

            if (campgrounds.Count > 0)
            {
                Console.WriteLine("".PadRight(10) + "Name".PadRight(35) + "Open".PadRight(20) + "Close".PadRight(20) + "Daily Fee".PadRight(20));
                campgrounds.ForEach(thing =>
                {
                    Console.WriteLine(thing);
                });
            }
            else
            {
                Console.WriteLine("NO RESULTS");
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Displays list of available campgrounds for selected park
        /// </summary>
        /// <param name="parkId"></param>
        /// <returns>The list of campgrounds available</returns>
        private IList <Campground> DisplayCampgroundInfo(int parkId)
        {
            CampgroundSqlDAL   dal         = new CampgroundSqlDAL(DatabaseConnection);
            IList <Campground> campgrounds = dal.GetCampgrounds(parkId);

            Console.Clear();
            if (campgrounds.Count > 0)
            {
                Console.WriteLine("CAMPGROUNDS");
                Console.WriteLine("ID".PadRight(10) + "Name".PadRight(40) + "Open".ToString().PadRight(10) + "Close".ToString().PadRight(10) + "Daily Fee".ToString().PadRight(10));


                foreach (Campground campground in campgrounds)
                {
                    Console.WriteLine((Convert.ToInt32(campground.CampgroundId)).ToString().PadRight(10) + campground.Name.PadRight(40) + campground.OpenMonth.ToString().PadRight(10) + campground.CloseMonth.ToString().PadRight(10) + campground.DailyFee.ToString("C2").PadRight(10));
                }
            }
            else
            {
                Console.WriteLine("**** NO CAMPGROUNDS TO SHOW ****");
            }
            return(campgrounds);
        }
        private void SearchForReservationMenu(Park selectedPark)
        {
            SiteSqlDAL        siteSqlDAL    = new SiteSqlDAL(connectionString);
            CampgroundSqlDAL  campgroundDAL = new CampgroundSqlDAL(connectionString);
            List <Campground> campgrounds   = campgroundDAL.GetCampgrounds(selectedPark);

            Console.WriteLine($"#:".PadRight(8) + "Campground Name".PadRight(41) + "Open From:".PadRight(16) + "Open To:".PadRight(16) + "Daily Fee".PadRight(5));
            foreach (Campground campground in campgrounds)
            {
                Console.WriteLine(campground.ToString());
            }

            Console.Write("Which campground? (enter 0 to cancel)");
            result[0] = Console.ReadLine();
            if (result[0] == "0")
            {
                input = "3";

                return;
            }
            Console.Write("What is the arrival date? (MM/DD/YYYY)");
            result[1] = Console.ReadLine();
            Console.Write("What is the departure date? (MM/DD/YYYY)");
            result[2] = Console.ReadLine();



            bool validCampgroundId = int.TryParse(result[0], out int campground_id);
            bool validFromDate     = DateTime.TryParse(result[1], out DateTime from_date);
            bool validToDate       = DateTime.TryParse(result[2], out DateTime to_date);

            if (DateTime.Compare(from_date, to_date) >= 0)
            {
                Console.WriteLine("Invalid Input, departure date is before arrival date. Press Enter to try again.");
                Console.ReadLine();

                return;
            }

            if (!validCampgroundId || !validFromDate || !validToDate)
            {
                Console.WriteLine("Invalid Input, Check Campground ID or Date Formats. Press Enter to try again.");
                Console.ReadLine();

                return;
            }

            bool containsId = false;

            foreach (Campground campground in campgrounds)
            {
                if (campground.Campground_id == campground_id)
                {
                    containsId = true;
                }
            }
            if (containsId)
            {
                reservation.Reservation_from_date = from_date;
                reservation.Reservation_to_date   = to_date;
                input = "5";
            }
            //else
            //{
            //    Console.Clear();
            //    Console.WriteLine("Invalid Input, Check Campground ID or Date Formats.");
            //    Console.WriteLine();
            //    input = "4";
            //    Console.Clear();
            //}
        }