Пример #1
0
        protected override void SetMenuOptions()
        {
            IList <Park> parks = parkDAO.GetAllParks();
            int          key   = 1;

            foreach (Park park in parks)
            {
                this.menuOptions.Add(key.ToString(), park.Name + " Park");
                key++;
            }

            // A Sample menu.  Build the dictionary here
            //this.menuOptions.Add("1", "Add 2 integers");
            //this.menuOptions.Add("2", "Ask the user for name");
            //this.menuOptions.Add("3", "Go to a sub-menu");
            this.menuOptions.Add("Q", "Quit program");
        }
Пример #2
0
        // Starting point of the program. First shows all parks in the system.
        public void Run()
        {
            // Account for can't parse string that isn't a number
            int tryParseInt;

            // Main menu - run until user types in Q
            while (true)
            {
                // Get a list of parks: Call method to query db table (park) for all entries
                IList <Park> parks         = parkDAO.GetAllParks();
                int          numberOfParks = 0;

                do //using a do to print the initial menu once and then check for valid input
                {
                    Console.WriteLine("Select from parks to view details");

                    // Loop through parks list returned and print out all the available parks
                    foreach (Park park in parks)
                    {
                        Console.WriteLine(park.ToString());
                        numberOfParks++; //Keep track of how many parks there are to validate input
                    }
                    // Option for user to quit
                    Console.WriteLine("(Q) Quit");

                    // Read in user choice
                    this.ParkChoice = Console.ReadLine();

                    if (this.ParkChoice.ToLower() == "q")
                    {
                        return;                                   // Quit if q
                    }
                    Console.Clear();
                } // while input is not valid, continue to prompt user to choose a valid park
                while ((int.TryParse(this.ParkChoice, out tryParseInt) == false) || int.Parse(ParkChoice) <= 0 || int.Parse(ParkChoice) > numberOfParks);

                // Save the chosen park here
                Park parkChoice = parkDAO.GetParkInfo(int.Parse(this.ParkChoice));
                Console.WriteLine("Park Information");

                // Print info for chosen park
                parkChoice.Display(parkChoice);

                // Call command menu (select campground/reservation for here)
                CampgroundMenu();
            }
        }
        public IActionResult Index()
        {
            IList <Park> parks = parkDAO.GetAllParks();

            return(View(parks));
        }