예제 #1
0
        private Park DisplayPark(string input)
        {
            Park        selectedPark = null;
            ParkSqlDAL  dal          = new ParkSqlDAL(connectionString);
            List <Park> parkInfo     = dal.GetAllParks();
            bool        parsed       = int.TryParse(input, out int selection);

            if (parsed)
            {
                if (selection <= parkInfo.Count() && selection != 0)
                {
                    selectedPark = parkInfo[selection - 1];
                    Console.WriteLine(selectedPark.ToString());
                    return(selectedPark);
                }
                else
                {
                    Console.Write("The park number you have selected is invalid, ");
                }
            }
            else
            {
                Console.Write("Please enter a park number or ");
            }
            return(selectedPark);
        }
        private void ShowAllNationalParks()
        {
            Console.WriteLine("Showing Parks");

            ParkSqlDAL dal = new ParkSqlDAL(connectionString);

            List <Park> allParks = dal.GetAllParks();

            foreach (Park p in allParks)
            {
                Console.WriteLine();
                Console.WriteLine("Park ID: " + p.Park_id);
                Console.WriteLine("Park Name: " + p.Name);
                Console.WriteLine("Park Location:" + p.Location);
                Console.WriteLine("Date of Park Establishment: " + p.Establish_date);
                Console.WriteLine("Park Size: " + p.Area);
                Console.WriteLine("Number of vistors in Park: " + p.Vistitors);
                Console.WriteLine("Description of Park: " + p.Description);
            }

            Console.WriteLine();
            Console.WriteLine("Would you Like to see a Parks campgrounds(Y/N)?");
            string input = Console.ReadLine().ToUpper();

            if (input == "Y")
            {
                int userInputParkId = CLIHelper.GetInteger("Please enter a Park Id");

                ShowAllCampgroundInAPark(userInputParkId);
            }
            return;
        }
        // GET: Index
        public ActionResult Index()
        {
            ParkSqlDAL  parkDAL  = new ParkSqlDAL(connectionString);
            List <Park> parkList = parkDAL.GetAllParks();

            return(View("Index", parkList));
        }
예제 #4
0
        public void GetAllParksTest()
        {
            ParkSqlDAL  sqlDAL = new ParkSqlDAL(connectionString);
            List <Park> park   = sqlDAL.GetAllParks();

            Assert.IsNotNull(park);
            Assert.AreEqual(numParks + 1, park.Count);
        }
        public void GetAllParksTest()
        {
            ParkSqlDAL  parkDAL  = new ParkSqlDAL(connectionString);
            List <Park> parkList = parkDAL.GetAllParks();

            Assert.IsNotNull(parkList);
            Assert.AreEqual(parks, parkList.Count);
        }
        public void GetAllParksTest()
        {
            ParkSqlDAL parkSqlDAL = new ParkSqlDAL(connectionString);

            List <Park> parks = parkSqlDAL.GetAllParks();

            Assert.IsNotNull(parks);
        }
        public void ListParks_Test()
        {
            ParkSqlDAL dal = new ParkSqlDAL(ConnectionString);

            var parks = dal.GetAllParks();
            int rows  = GetRowCount("park");

            Assert.AreEqual(rows, parks.Count);
        }
        private Park GetParks()
        {
            ParkSqlDAL  dal   = new ParkSqlDAL(connectionString);
            List <Park> parks = dal.GetAllParks();
            //Park selectedPark = new Park();


            bool menuOpen = true;

            while (menuOpen)
            {
                int menuCounter = 1;
                Console.WriteLine("Select a Park for Further Details: ");
                foreach (Park park in parks)
                {
                    Console.WriteLine(menuCounter++ + ")" + park.Park_name);
                }
                Console.WriteLine("Q) Quit");

                string userInput = Console.ReadLine();
                // Console.Clear();

                bool number = int.TryParse(userInput, out int parkNumber);
                if (!(number))
                {
                    if (userInput.ToLower() == "q")
                    {
                        input    = "q";
                        menuOpen = false;
                        return(selectedPark);
                    }
                    else
                    {
                        Console.WriteLine("Please select a valid menu option. Press enter to try again.");
                        Console.ReadLine();
                    }
                }
                else
                {
                    if (parkNumber <= parks.Count() && parkNumber != 0)
                    {
                        selectedPark = parks[parkNumber - 1];
                        Console.WriteLine(selectedPark.ToString());
                        menuOpen = false;
                        input    = "2";
                    }
                    else
                    {
                        Console.WriteLine("Please select a valid menu option. Press enter to try again.");
                        Console.ReadLine();
                    }
                }
                Console.Clear();
            }
            return(selectedPark);
        }
예제 #9
0
        //this method loads the dictionary for Park details in CLI
        public void PopulateParksDictionary()
        {
            ParkSqlDAL  parkDal  = new ParkSqlDAL(DatabaseConnection);
            List <Park> parkList = parkDal.GetAllParks();

            for (int i = 0; i < parkList.Count; i++)
            {
                _parks.Add(i, parkList[i]);
            }
        }
예제 #10
0
 public void GetAllParks()
 {
     using (TransactionScope transaction = new TransactionScope())
     {
         int              newParkId = ParkSqlDALTests.InsertFakePark(park);
         ParkSqlDAL       testClass = new ParkSqlDAL(connectionString);
         List <ParkModel> parks     = testClass.GetAllParks();
         Assert.IsTrue(parks.Select(park => park.ParkId).Contains(newParkId));
     }
 }
예제 #11
0
        public void GetAllParksTest()
        {
            List <Parks> result = new List <Parks>();

            ParkSqlDAL parks = new ParkSqlDAL(connectionString);

            result = parks.GetAllParks();

            Assert.AreEqual(10, result.Count);
        }
예제 #12
0
        /// <summary>
        /// Runs the CLI for the national park system.
        /// </summary>
        public void Run()
        {
            ParkSqlDAL  p     = new ParkSqlDAL(ConnectionString);
            List <Park> parks = p.GetAllParks();

            parks.Insert(0, null); // 1-index parks to align with menu options

            while (true)
            {
                DisplayParkSelectionMenu(parks);
                int parkSelection = CLIHelper.GetIntegerOrQ(">>", 1, parks.Count - 1);

                if (parkSelection == parks.Count)
                {
                    // Quit at Main Menu
                    break;
                }

                while (!returnToMainMenu)
                {
                    DisplayParkDetailMenu(parks[parkSelection]);
                    int parkOption = CLIHelper.GetIntegerInRange(">>", 1, 3);

                    if (parkOption == 1)
                    {
                        DisplayCampgroundsList(parks[parkSelection]);
                        DisplayCampgroundsMenu();

                        int campgroundOption = CLIHelper.GetIntegerInRange(">>", 1, 2);

                        if (campgroundOption == 1)
                        {
                            List <Campground> campgrounds = DisplayCampgroundsList(parks[parkSelection]);
                            int cgSelection = CLIHelper.GetIntegerInRange("Which campground (enter 0 to cancel)?",
                                                                          0, campgrounds.Count - 1);

                            if (cgSelection != 0)
                            {
                                ManageAvailableSiteSearch(campgrounds[cgSelection]);
                                CompletionMessageAndReturnToMainMenu();
                            }
                        }
                    }
                    else if (parkOption == 2)
                    {
                        ManageAvailableSiteSearch(parks[parkSelection]);
                        CompletionMessageAndReturnToMainMenu();
                    }
                    else if (parkOption == 3)
                    {
                        break;
                    }
                }
            }
        }
예제 #13
0
        public void GetAllParks()
        {
            // Arrange
            ParkSqlDAL dal = new ParkSqlDAL(ConnectionString);

            // Act
            IList <Park> parks = dal.GetAllParks();

            // Assert
            Assert.AreEqual(1, parks.Count);
        }
        public void GetAllParksTest()
        {
            //Arrange
            ParkSqlDAL parkSqlDal = new ParkSqlDAL(connectionString);

            //Act
            List <Park> parks = parkSqlDal.GetAllParks();

            //Assert
            Assert.IsNotNull(parks);
            Assert.AreEqual(numberOfParks, parks.Count);
        }
        /// <summary>
        /// Displays all the parks that are in the database and stores them in a list.
        /// </summary>
        private List <Park> DisplayAllParks()
        {
            ParkSqlDAL  dal   = new ParkSqlDAL(DatabaseConnection);
            List <Park> parks = dal.GetAllParks();

            foreach (Park park in parks)
            {
                Console.WriteLine($"{park.Id.ToString()}) {park.Name}");
            }

            return(parks);
        }
예제 #16
0
        public void GetAllParksTest() //IList<Park> GetAllParks()
        {
            //Arrange
            IParkDAL parkSqlDAL = new ParkSqlDAL(connectionString);

            //ACT
            IList <Park> parks = parkSqlDAL.GetAllParks();

            //Assert
            Assert.IsNotNull(parks, "Parks list is empty!");
            Assert.AreEqual(parkCount, parks.Count, $"Expected a count of {parkCount} for parks");
        }
예제 #17
0
        private void GetParks()
        {
            ParkSqlDAL  dal         = new ParkSqlDAL(connectionString);
            List <Park> parks       = dal.GetAllParks();
            int         menuCounter = 1;

            Console.WriteLine("Select a Park for Further Details: ");
            foreach (Park park in parks)
            {
                Console.WriteLine(menuCounter++ + ")" + park.Park_name);
            }
            Console.WriteLine("Q) Quit");
        }
예제 #18
0
        private void DisplayParks()
        {
            _parks.Clear();
            List <Park> parksList = _parkDal.GetAllParks();

            Console.WriteLine();

            for (int index = 0; index < parksList.Count; index++)
            {
                Park park = parksList[index];
                Console.WriteLine($"{index + 1}) {park.Name}");
                _parks.Add(index + 1, park);
            }
        }
예제 #19
0
        ///Print All Parks
        public void PrintParks()
        {
            ParkSqlDAL  dal   = new ParkSqlDAL(DatabaseConnection);
            List <Park> parks = dal.GetAllParks();

            _parkDictionary.Clear();

            for (int i = 1; i <= parks.Count; i++)
            {
                Park park = parks[i - 1];
                Console.WriteLine($"{i}) {parks[i-1].Name} National Park");
                _parkDictionary.Add(i, park);
            }
        }
예제 #20
0
        public bool ViewParks()
        {
            ParkSqlDAL  park     = new ParkSqlDAL(connectionString);
            List <Park> allParks = park.GetAllParks();
            int         count    = 1;

            Console.Clear();
            Console.WriteLine("Select a Park for Further Details");
            foreach (Park p in allParks)
            {
                Console.WriteLine($"{count}) {p.Name}");
            }
            //Console.WriteLine("1) Acadia");
            //Console.WriteLine("2) Arches");
            //Console.WriteLine("3) Cuyahoga National Valley Park");
            Console.WriteLine();
            Console.WriteLine("Q) quit");
            Console.WriteLine();

            string command = Console.ReadLine();

            switch (command.ToLower())
            {
            case command_Arcadia:
                GetParkInfo(allParks[0]);
                break;

            case command_Arches:
                GetParkInfo(allParks[1]);
                break;

            case command_Cuyahoga:
                GetParkInfo(allParks[2]);
                break;

            case command_Quit:
                Environment.Exit('q');
                break;

            default:
                Console.WriteLine("The command provided was not a valid command, please try again.");
                break;
            }
            return(true);
        }
예제 #21
0
        // LEVEL: PARKS ///////////////////////////////////////////////
        private void GetAllParks_View()
        {
            ParkSqlDAL dal = new ParkSqlDAL(DatabaseConnection);

            this.AllParks = dal.GetAllParks();

            if (this.AllParks.Count > 0)
            {
                foreach (Park park in this.AllParks)
                {
                    this.PrintOption(park.Park_Id.ToString(), park.Name);
                }
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
            }
        }
        public void GetAllParksTest()
        {
            ParkSqlDAL parkSqlDAL = new ParkSqlDAL(connectionString);

            List <Park> parks = parkSqlDAL.GetAllParks();

            bool found = false;

            foreach (Park park in parks)
            {
                if (park.Code == "AAA")
                {
                    found = true;
                }
            }

            Assert.AreEqual(true, found, "Park AAA not found in test");
            Assert.IsNotNull(parks);
        }
예제 #23
0
        public void ParkMenu()
        {
            Console.WriteLine("National Parks");
            Console.WriteLine();
            ParkSqlDAL  parkSql  = new ParkSqlDAL(connectionString);
            List <Park> parkList = parkSql.GetAllParks();
            int         parkChoice;
            bool        done = false;

            for (int i = 1; i <= parkList.Count; ++i)
            {
                // print i + park.name;
                Console.WriteLine($"{i}) {parkList[i - 1].Name}");
            }

            Console.WriteLine("0) quit");

            while (!done)
            {
                Console.WriteLine();
                Console.Write("Choice: ");

                bool isNumeric = int.TryParse(Console.ReadLine(), out parkChoice);

                while (!isNumeric || parkChoice > parkList.Count || parkChoice < 0)
                {
                    Console.Write("Please enter a valid selection: ");
                    isNumeric = int.TryParse(Console.ReadLine(), out parkChoice);
                    Console.WriteLine();
                }

                if (parkChoice <= parkList.Count && parkChoice > 0)
                {
                    CMDMenu(parkChoice);
                }
                else if (parkChoice == 0)
                {
                    Environment.Exit(0);
                }
            }
        }
예제 #24
0
        public ActionResult Index()
        {
            ParkSqlDAL   parkDAL = new ParkSqlDAL(connectionString);
            List <Parks> model   = parkDAL.GetAllParks();

            string result = Request.QueryString["celsius"];

            if (result != null)
            {
                if (result.Contains("true"))
                {
                    Session["Celsius"] = "C";
                }
                else
                {
                    Session["Celsius"] = "F";
                }
            }

            return(View("Index", model));
        }
예제 #25
0
        public void GetAllParks_ReturnsNewlyAddedPark()
        {
            using (TransactionScope transaction = new TransactionScope())
            {
                // Arrange
                ParkSqlDAL testClass = new ParkSqlDAL(connectionString);
                Park       tempPark  = new Park();
                tempPark.Area           = 0;
                tempPark.Description    = "TEST DESCRIPTION";
                tempPark.Establish_Date = new DateTime(2000, 1, 1).Date;
                tempPark.Location       = "TEST LOCATION";
                tempPark.Name           = "TEST PARK";
                tempPark.Visitors       = 0;
                int tempPark_parkId = InsertFakePark(tempPark);

                // Act
                List <Park> parks = testClass.GetAllParks();

                // Assert
                Assert.IsTrue(parks.Select(p => p.Park_id).Contains(tempPark_parkId));
            }
        }
예제 #26
0
        public IActionResult Index()
        {
            var parks = pdal.GetAllParks();

            return(View(parks));
        }
예제 #27
0
        public void RunCLI()
        {
            string      input        = "";
            string      input2       = "2";
            ParkSqlDAL  dal          = new ParkSqlDAL(connectionString);
            List <Park> parksList    = dal.GetAllParks();
            Park        selectedPark = null;

            while (true)
            {
                GetParks();                             //prints out the list of all possible parks to choose from
                input = Console.ReadLine();
                Console.Clear();
                if (input.ToUpper() == "Q")              //if User selects to quit, program ends
                {
                    return;
                }

RestartDisplayPark:

                selectedPark = DisplayPark(input);

                if (selectedPark == null)
                {
                }                                 //displays all information about a single park, unless the selected park is null
                else if (selectedPark != null)
                {
                    input = null;
                    while (input == null)
                    {
                        ParkInfoMenu();                     // 3 options: view campgrounds, search reservation, or previous screen
                        input = Console.ReadLine();
                        Console.Clear();
                    }
                }

                if (input == "1")
                {
RestartViewCampGround:
                    ViewCampgrounds(selectedPark);  //all campgrounds of a selected park
                    CamprgroundMenu();              // 2 options: search for reservation, previous screen
                    input2 = Console.ReadLine();
                    Console.Clear();

                    if (input2 == "1")
                    {
                        if (SearchForReservationMenu(selectedPark))
                        {
                            MakeReservationMenu();
                        }
                        else
                        {
                            goto RestartViewCampGround;
                        }
                    }
                    else if (input2 == "2")
                    {
                        goto RestartDisplayPark;
                    }
                    else
                    {
                        Console.WriteLine("Please select a valid menu option.");
                        goto RestartViewCampGround;
                    }
                }
                else if (input == "2")
                {
                    // RestartReservationMenu:
                    if (SearchForReservationMenu(selectedPark))
                    {
                        MakeReservationMenu();
                    }
                    else
                    {
                        //  goto
                    }
                }
                else if (input == "3")
                {
                }
                else
                {
                    Console.WriteLine("please select a valid menu option.");
                    Console.WriteLine();
                }
            }
        }