/// <summary>
        /// Allows the user to view all of the information for any given park
        /// If the user presses "Q" or "q", they will be brought to the previous menu
        /// </summary>
        public void RunCLI()
        {
            this.PrintMenu();
            string input = Console.ReadLine().ToUpper();

            if (input == "Q")
            {
                return;
            }

            int parkSelection = int.Parse(input);

            Park selectedPark = this.parks[parkSelection - 1];

            Console.Clear();
            Console.WriteLine($"Park Information Screen");
            Console.WriteLine($"{selectedPark.Name}");
            Console.WriteLine($"Location: {selectedPark.Location}");
            Console.WriteLine($"Established: {selectedPark.Establish_Date.ToShortDateString()}");
            Console.WriteLine($"Area: {selectedPark.Area} sq km");
            Console.WriteLine($"Annual Visitors: {selectedPark.Visitors}");
            Console.WriteLine();
            Console.WriteLine($"{selectedPark.Description}");
            Console.WriteLine();
            ICampground         dal             = new CampgroundSqlDAL(DatabaseConnectionString);
            IList <Campground>  campgrounds     = dal.GetAllCampgrounds(selectedPark.Park_Id);
            ParkCampgroundsMenu campgroundsMenu = new ParkCampgroundsMenu(campgrounds);

            campgroundsMenu.RunCLI();
            return;
        }
        private IList <Campground> GetAllCampgrounds(int park_Id)
        {
            ICampground        dal        = new CampgroundSqlDAL(DatabaseConnectionString);
            IList <Campground> campground = dal.GetAllCampgrounds(park_Id);

            return(campground);
        }
        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 void GetAllCampgroundsTest()
        {
            int parkId;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("INSERT INTO park VALUES ('fake park', 'fake location', '9/9/9999', 99, 99, 'fake description');", conn);
                cmd.ExecuteNonQuery();

                cmd    = new SqlCommand("SELECT CAST(SCOPE_IDENTITY() as int);", conn);
                parkId = Convert.ToInt32(cmd.ExecuteScalar());
            }

            int campgroundId;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand($"INSERT INTO campground VALUES ({parkId}, 'fake campground', '1', '2', '99');", conn);
                cmd.ExecuteNonQuery();

                cmd          = new SqlCommand("SELECT CAST(SCOPE_IDENTITY() as int);", conn);
                campgroundId = Convert.ToInt32(cmd.ExecuteScalar());
            }

            CampgroundSqlDAL  dal        = new CampgroundSqlDAL(connectionString);
            List <Campground> campground = dal.GetAllCampgrounds(parkId);

            CollectionAssert.Contains(campground, campgroundId);
        }
        public void GetAllCampgroundsTest()
        {
            CampgroundSqlDAL  campgroundDAL   = new CampgroundSqlDAL(connectionString);
            List <Campground> campgroundsList = campgroundDAL.GetAllCampgrounds();

            Assert.IsNotNull(campgroundsList);
            Assert.AreEqual(campgrounds, campgroundsList.Count);
        }
示例#6
0
        //this method loads the Campground Dictionary for use in CLI
        public void PopulateCampgroundDictionary()
        {
            CampgroundSqlDAL  campDal  = new CampgroundSqlDAL(DatabaseConnection);
            List <Campground> campList = campDal.GetAllCampgrounds();

            for (int i = 0; i < campList.Count; i++)
            {
                _campgrounds.Add(i, campList[i]);
            }
        }
示例#7
0
        private void DisplayCampgrounds(Park park)
        {
            _campgrounds.Clear();
            List <Campground> campgroundsList = _campgroundDAL.GetAllCampgrounds(park);

            Console.WriteLine();

            for (int index = 0; index < campgroundsList.Count; index++)
            {
                Campground campground = campgroundsList[index];
                Console.WriteLine("{0, -4}{1, -20}{2, -20}{3, -20}{4, -20}", "#" + (index + 1), campground.Name, campground.OpenFromMonthStr, campground.OpenToMonthStr, campground.DailyFee.ToString("c"));
                _campgrounds.Add(index + 1, campground);
            }
        }
        public void Display(Park park)
        {
            ICampgroundDAL campgroundsInPark = new CampgroundSqlDAL(databaseConnection);
            //campgroundsInPark.GetAllCampgrounds(park.ParkId);
            List <Campground> campgrounds = campgroundsInPark.GetAllCampgrounds(park.ParkId);

            Console.WriteLine("Camp ID".PadRight(10) + "Camp Name".PadRight(35) + "Camp Open Date".PadRight(20) + "Camp Closing Date".PadRight(20) + "Daily Fee".PadRight(20));
            foreach (Campground camp in campgrounds)
            {
                Console.WriteLine(camp.CampgroundId.ToString().PadRight(10) + camp.Name.PadRight(35) + camp.GetMonthName(camp.Open_From).PadRight(20) + camp.GetMonthName(camp.Open_To).PadRight(20) + camp.DailyFee.ToString("C2").PadRight(20));
            }

            Console.WriteLine();
            CampGroundChoices(campgrounds);
        }
示例#9
0
        public void PrintAllCampgrounds()
        {
            CampgroundSqlDAL  cgDAL          = new CampgroundSqlDAL(connectionString);
            List <Campground> campgroundList = cgDAL.GetAllCampgrounds();

            Console.WriteLine("\n".PadRight(5) + "Name" + "Open".PadLeft(35) +
                              "Close".PadLeft(11) + "Daily Fee".PadLeft(20));

            for (int i = 1; i <= campgroundList.Count; ++i)
            {
                // print i + park.name;
                Console.WriteLine($"#{i.ToString().PadRight(3)}{campgroundList[i - 1].Name.ToString().PadRight(35)}" +
                                  $"{ConvertMonthToString(campgroundList[i - 1].Open_from_mm).ToString().PadRight(10)}" +
                                  $"{ConvertMonthToString(campgroundList[i - 1].Open_to_mm).ToString().PadRight(15)}" +
                                  $"{campgroundList[i - 1].Daily_fee.ToString("C2").PadLeft(10)}");
            }
        }