Beispiel #1
0
        private void DisplayCampgroundInfo(Park park)
        {
            Console.Clear();

            ParkSqlDAL        campgroundDal = new ParkSqlDAL(_dbConnectionString);
            List <Campground> campgrounds   = campgroundDal.GetCampgrounds(park.ParkId);

            menus.SelectedParkCampgroundInfo(park);

            bool exit = false;

            while (!exit)
            {
                menus.ParkCampgroundsInfo(campgrounds);

                string command = Console.ReadLine();
                int    selection;

                if (command == "q" || command == "Q")
                {
                    menus.QuitMenu();
                    exit = true;
                }
                else if (command == "m" || command == "M")
                {
                    DisplayMenu();
                }
                else if (int.TryParse(command, out selection))
                {
                    if (selection > 0 && selection <= campgrounds.Count)
                    {
                        Console.Clear();
                        DisplaySiteInfoForSelectedCampground(campgrounds[selection - 1]);
                    }
                    else
                    {
                        menus.InvalidEntry();
                    }
                }
                else
                {
                    menus.InvalidEntry();
                }

                Console.ReadKey();
                Console.Clear();
            }
        }
        private void DisplayCampgroundInfo(Park park)
        {
            Console.Clear();

            ParkSqlDAL        campgroundDal = new ParkSqlDAL(_dbConnectionString);
            List <Campground> campgrounds   = campgroundDal.GetCampgrounds(park.ParkId);

            //display campground info for selected park
            Console.WriteLine();
            Console.WriteLine(" " + park.ParkName + " Campgrounds");
            Console.WriteLine();
            Console.WriteLine(" {0,0} {1,10} {2,30} {3,15} {4,15}", " ", "Name", "Opens", "Closes", "Daily Fee");
            Console.WriteLine();

            bool exit = false;

            while (!exit)
            {
                for (int index = 0; index < campgrounds.Count; index++)
                {
                    Console.WriteLine(" " + (index + 1) + ") " + campgrounds[index].CampgroundName.PadRight(35) +
                                      " " + campgrounds[index].MonthOpenStr.PadRight(15) +
                                      " " + campgrounds[index].MonthCloseStr.PadRight(15) +
                                      " " + campgrounds[index].DailyFee.ToString("c"));
                }

                //menu for selecting a campground to view site info
                Console.WriteLine();
                Console.WriteLine(" Menu Options ");
                Console.WriteLine();
                Console.WriteLine(" P) Return to Selected Park");
                Console.WriteLine(" M) Return to Main Parks Menu");
                Console.WriteLine(" Q - Quit");
                Console.WriteLine();
                Console.Write(" Select an option... or ");
                Console.WriteLine();
                Console.WriteLine(" Select a campground to view site information and submit reservation requests... ");

                string command = Console.ReadLine();
                int    selection;

                if (command == "q" || command == "Q")
                {
                    DisplayQuitApplication();
                    exit = true;
                }
                else if (command == "m" || command == "M")
                {
                    DisplayMainMenu();
                }
                else if (command == "p" || command == "P")
                {
                    DisplayParkInfoMenu(park);
                }
                else if (int.TryParse(command, out selection))
                {
                    if (selection > 0 && selection <= campgrounds.Count)
                    {
                        Console.Clear();
                        RequestReservationMenu(campgrounds[selection - 1]);
                    }
                }
                else
                {
                    DisplayInvalidRequest();
                }

                Console.ReadKey();
                Console.Clear();
            }
        }