public void RunCLI()
        {
            ParkDAL     parkDAL = new ParkDAL(connectionString);
            List <Park> parks   = parkDAL.GetParks();

            Console.Clear();
            Console.WriteLine("Select a Park for Further Details");
            int i = 1;  //menu index

            foreach (Park park in parks)
            {
                Console.WriteLine(i.ToString() + ")".PadRight(4) + park.Name);
                i++;
            }

            Console.WriteLine("Q)".PadRight(4) + " Quit");

            string input = CLIHelper.GetString("Please enter a selection: ");

            if (input.ToLower().Equals("q"))
            {
                Environment.Exit(1);
            }
            else if (int.Parse(input) > 0 && int.Parse(input) < i)
            {
                ViewParkInfo(parks[int.Parse(input) - 1].ParkID);
            }
            else
            {
                Console.WriteLine("Make a valid selection");
            }
            return;
        }
        } //WarningMessageFormat

        private string parkNameDisplay(int park_Id)
        {
            ParkDAL parkDal = new ParkDAL(DatabaseConnection);
            Park    park    = parkDal.GetPark(park_Id);

            return($"{park.Name}");
        }//parkNameDisplay
        }//MainMenu

        private int MainMenuDisplayAllParks()
        {
            int numberOfParks = 0;

            FlowerLine();

            ParkDAL      parkDal = new ParkDAL(DatabaseConnection);
            IList <Park> parks   = parkDal.GetAllParks();

            numberOfParks = parks.Count;

            if (numberOfParks > 0)
            {
                foreach (Park park in parks)
                {
                    Console.WriteLine(park.ToString());
                }
            }
            else //no parks returned
            {
                Console.WriteLine("**** NO RESULTS ****");
            }

            return(numberOfParks);
        }//DisplayAll
        private void ChooseDisplayParkInfo()
        {  //this shows park information based on choice
            tempParkId = CLIHelper.GetInteger("Please enter in the Park ID for more information:");
            ParkDAL dal = new ParkDAL(DatabaseConnection);

            IList <Park> parks = dal.DisplayParkInfo(tempParkId);

            Console.WriteLine("Park Information:");
            Console.WriteLine();

            if (parks.Count > 0)
            {
                foreach (Park park in parks)
                {
                    Console.WriteLine(park.Name.ToString() + Environment.NewLine + "Location: " + park.Location + Environment.NewLine + "Established: " + park.EstablishDate.ToShortDateString() + Environment.NewLine + "Area: " + (park.Area.ToString("N0")) + " sq km" + Environment.NewLine + "Annual Vistors: " + park.Visitors.ToString("N0"));
                    Console.WriteLine();
                    Console.WriteLine(park.Description);
                    Console.WriteLine();
                }
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
            }
            Console.WriteLine();
            DisplayParkOptions();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            // Get the connection string from the appsettings.json file
            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .SetBasePath(Directory.GetCurrentDirectory())
                                            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            string connectionString = configuration.GetConnectionString("Project");

            /********************************************************************
             * // If you do not want to use CLIMenu, you can remove the following
             *********************************************************************/
            // Create any DAOs needed here, and then pass them into main menu...
            ParkDAL        parkDal        = new ParkDAL(connectionString);
            CampgroundDAL  campDal        = new CampgroundDAL(connectionString);
            SiteDAL        siteDal        = new SiteDAL(connectionString);
            ReservationDAL reservationDAL = new ReservationDAL(connectionString);



            MainMenu mainMenu = new MainMenu(parkDal, campDal, siteDal, reservationDAL);  // You'll probably be adding daos to the constructor

            //Run the menu.
            mainMenu.Run();
        }
        public List <Park> GetAllParks()
        {
            ParkDAL dal = new ParkDAL(DatabaseConnectionString);

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

            return(parks);
        }
Exemple #7
0
        public void ParkInfoScreen(int parkID)
        {
            while (true)
            {
                string header = "";

                string selectionMenu = "Select a Command\n----------------\n1) View campgrounds\n2) Search for reservation\n3) View all reservations for the next 30 days\n4) Return to previous screen\n";

                string selectionPrompt = "Selection:";

                Park         currentWorkingPark = new Park();
                ParkDAL      parkDAL            = new ParkDAL(DatabaseConnection);
                IList <Park> parks = parkDAL.GetParkList();

                foreach (Park park in parks)
                {
                    if (park.ParkID == parkID)
                    {
                        currentWorkingPark = park;
                        Console.Clear();
                        header += $"====================== {currentWorkingPark.Name} National Park Information ======================";
                        Console.SetCursorPosition((Console.WindowWidth - header.Length) / 2, Console.CursorTop);
                        Console.WriteLine(header);
                        Console.WriteLine(park.ToString() + "\n");
                        break;
                    }
                }

                int command;

                Console.WriteLine(selectionMenu);
                command = CLIHelper.GetInteger(selectionPrompt);


                switch (command)
                {
                case (1):
                    ParkCampgroundScreen(currentWorkingPark);
                    break;

                case (2):
                    ParkWideAvailabilitySearch(parkID);    //Search reservations by park
                    break;

                case (3):
                    Display30DaysReservation(parkID);
                    break;

                case (4):
                    return;

                default:
                    Console.WriteLine("Please enter a valid number from the menu.  Press Enter to try again.");
                    Console.ReadLine();
                    break;
                }
            }
        }
        }//DisplayParkInformationMenu

        private void DisplayParkInformationList(int parkMenuSelectionInt)
        {
            //displays selected park information formatted based on requirments sample screen
            ParkDAL parkDal = new ParkDAL(DatabaseConnection);
            Park    park    = parkDal.GetPark(parkMenuSelectionInt);

            Console.WriteLine($"\n{park.Name} National Park");
            Console.WriteLine($"{"Location:".PadRight(18)}{park.Location.ToString()}");
            Console.WriteLine($"{"Established:".PadRight(18)}{ park.Establish_Date.ToString("MM/dd/yyyy")}");
            Console.WriteLine($"{"Area:".PadRight(18)}{(park.Area).ToString("N0")} acres");
            Console.WriteLine($"{"Annual Visitors:".PadRight(18)}{park.Visitors.ToString("N0")}");
            Console.WriteLine($"\n{park.Description}\n");
        }//DisplayParkInformationList
Exemple #9
0
        public List <Park> PrintAllParks()
        {
            ParkDAL     dal     = new ParkDAL();
            List <Park> parks   = dal.GetAllParks();
            int         counter = 1;

            foreach (Park park in parks)
            {
                Console.WriteLine(counter + ")" + " " + park.Name);
                counter++;
            }
            Console.WriteLine("0) Quit Program");
            return(parks);
        }
Exemple #10
0
        public void InformationForSelectedPark(int userInput)
        {
            ParkDAL parkDAL = new ParkDAL(connectionString);
            Park    park    = parkDAL.GetChosenPark(userInput);

            bool isDone = false;

            do
            {
                Console.WriteLine(park.ToString());

                isDone = ParkInformationMenu(park); //returns to previous menu if user presses zero in ParkInformationMenu
            }while (!isDone);
            return;
        }
Exemple #11
0
        private void ShowAllParks()
        {
            Console.WriteLine("SHOWING ALL PARKS");
            ParkDAL      dal       = new ParkDAL(connectionString);
            List <Parks> parksList = dal.GetListOfParks();

            foreach (Parks p in parksList)
            {
                Tools.ColorfulWriteLine("Park ID".PadRight(10) + "Park Name".PadRight(20) + "Location".PadRight(10) + "Date Established".PadRight(30) + "Area".PadRight(10) + "Annual Vistors".PadRight(10), ConsoleColor.Green);
                Console.WriteLine($"{p.Id} )".PadRight(10) + $"{p.Name}".PadRight(20) + $"{p.Location}".PadRight(10) + $"{p.EstablishedDate}".PadRight(30) + $"{p.Area}".PadRight(10) + $"{p.Visitors}");
                Console.WriteLine();
                Tools.ColorfulWriteLine("Park Description", ConsoleColor.Yellow);
                Console.WriteLine(p.Description);
                Console.WriteLine();
            }
        }
        public void ViewParkInfo(int parkID)
        {
            ParkDAL park    = new ParkDAL(connectionString);
            Park    curPark = park.GetParkInfo(parkID);

            Console.Clear();
            Console.WriteLine(curPark);
            bool invalidSelection = false;

            do
            {
                Console.WriteLine("Select a Command");
                Console.WriteLine(" 1) View Campgrounds");
                Console.WriteLine(" 2) View Reservations within 30 days");
                Console.WriteLine(" 3) Search for Reservation");
                Console.WriteLine(" 4) Return to Park Selection Screen");

                string input = CLIHelper.GetString("Please enter a selection: ");

                switch (input)
                {
                case "1":
                    ViewCampgrounds(parkID);
                    break;

                case "2":
                    ViewParkReservations(parkID);
                    break;

                case "3":
                    MakeReservation(parkID, 0);
                    break;

                case "4":
                    invalidSelection = false;
                    break;

                default:
                    Console.WriteLine("Please make a valid selection.");
                    invalidSelection = true;
                    break;
                }
            } while (invalidSelection);

            return;
        }
        private void ViewParksMenu()
        {
            Park selectedPark = new Park();

            //assemble and display list of parks from database

            ParkDAL     dal   = new ParkDAL(DatabaseConnection);
            List <Park> parks = dal.ViewParksMenu();

            Console.WriteLine();
            Console.WriteLine("VIEW PARKS INTERFACE");
            Console.WriteLine();
            Console.WriteLine("Select a Park for Further Details");

            foreach (Park thisPark in parks)
            {
                Console.WriteLine(thisPark.Marker + ") " + thisPark.Name);
            }
            Console.WriteLine("Q) Quit");

            //user chooses option, loop through parks to match by ID

            string userInput = Console.ReadLine().ToUpper();

            if (userInput == "Q")
            {
                Environment.Exit(0);
            }
            int userInt = int.TryParse(userInput, out userInt) ? userInt : 0;

            bool parkAssigned = false;

            foreach (Park thisPark in parks)
            {
                if (thisPark.Marker == userInt)
                {
                    selectedPark = thisPark;
                    parkAssigned = true;
                }
            }
            if (parkAssigned)
            {
                DisplayParkInfo(selectedPark);
            }
        }
Exemple #14
0
        public bool IsValidParkId(int userSelectedParkId)
        {
            ParkDAL     parkDAL = new ParkDAL(connectionString);
            List <Park> parks   = parkDAL.GetParks();

            int invalidCount = 0;

            foreach (Park park in parks)
            {
                if (park.Id != userSelectedParkId)
                {
                    invalidCount++;
                }
            }
            if (invalidCount == parks.Count)
            {
                return(false);
            }
            return(true);
        }
Exemple #15
0
        public void ParkInformation(string parkId)
        {
            ParkDAL          thisPark     = new ParkDAL(connectionString);
            List <ParkModel> parkInfoList = thisPark.GetAllParks();

            Console.WriteLine("Park Information");

            for (int i = 0; i < parkInfoList.Count; i++)//loops through to build park information from park model
            {
                if (parkId == parkInfoList[i].ParkId.ToString())
                {
                    Console.WriteLine(parkInfoList[i].ParkName + " National Park");
                    Console.WriteLine("Location:" + parkInfoList[i].ParkLocation.PadLeft(20));
                    Console.WriteLine("Established:".PadRight(24) + parkInfoList[i].ParkEstablishDate.Date.ToShortDateString());
                    Console.WriteLine("Area:" + parkInfoList[i].Area.ToString().PadLeft(24) + " sq km");
                    Console.WriteLine("Annual Visitors:" + parkInfoList[i].Visitors.ToString().PadLeft(15));
                    Console.WriteLine();
                    WrapText(parkInfoList[i].ParkDescription);
                }
            }
        }
        private void DisplayParks()
        {  //this diplays all of the parks in the DB
            ParkDAL      dal   = new ParkDAL(DatabaseConnection);
            IList <Park> parks = dal.GetAllParks();

            Console.WriteLine("PARK LISTING" + Environment.NewLine);
            Console.WriteLine(("").PadRight(5) + ("Park ID").PadRight(10) + ("Name").PadRight(5));
            if (parks.Count > 0)
            {
                foreach (Park park in parks)
                {
                    Console.WriteLine((park.Rownumber.ToString()).PadRight(5) + park.ParkId.ToString().PadRight(10) + (park.Name).PadRight(30));
                }
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
            }
            Console.WriteLine();
            Console.WriteLine("Q".PadRight(5) + "Quit");
            Console.WriteLine();
            ChooseDisplayParkInfo();
        }
Exemple #17
0
        public void Run()
        {
            bool isDone = false;

            ParkDAL     parkDAL = new ParkDAL(connectionString);
            List <Park> parks   = parkDAL.GetParks();

            do
            {
                ParkInfoMenu(parks);
                try
                {
                    int userSelection = Int32.Parse(Console.ReadLine());

                    if (userSelection == 0)
                    {
                        isDone = true;
                        return;
                    }
                    else if (!IsValidParkId(userSelection))
                    {
                        Console.WriteLine("");
                        Console.WriteLine("Sorry, that is not a valid park ID.");
                    }
                    else
                    {
                        InformationForSelectedPark(userSelection);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine();
                    Console.WriteLine("Not a valid input- please try again");
                }
            }while (!isDone);
        }
Exemple #18
0
        public void ParkMenu()
        {
            ParkDAL          allParks      = new ParkDAL(connectionString);
            List <ParkModel> compiledParks = allParks.GetAllParks();//creates list of parks for menu

            Console.WriteLine("Select a Park for Further Details ");

            for (int i = 0; i < compiledParks.Count; i++)//loops through the list to display each park name in database
            {
                Console.WriteLine($"{compiledParks[i].ParkId}) {compiledParks[i].ParkName}");
            }
            Console.WriteLine($"Press Q to Quit");
            Console.WriteLine();
            string parkId = Console.ReadLine();

            foreach (ParkModel item in compiledParks)//loop to check if user input matches park id
            {
                if (parkId.ToLower() == "q")
                {
                    Environment.Exit(0);
                }
                else if (parkId != item.ParkId.ToString())
                {
                    //Console.WriteLine("Please Select Valid Option");
                    //Console.ReadLine();
                    //Console.Clear();
                    //SEE IF YOU CAN FIGURE OUT HOW TO NOT WRITE THSI MESSAGE 10000 TIMES
                    //Console.WriteLine("Please make a valid selection ");
                }
                else
                {
                    Console.Clear();
                    ParkInformationMenu(parkId);
                }
            }
        }
        public void GetParkInfo(int parkId)
        {
            ParkDAL dal = new ParkDAL(DatabaseConnectionString);

            Console.WriteLine($"{dal.GetParkById(parkId)}");
        }
Exemple #20
0
        public void RunCLI()
        {
            while (true)
            {
                string parkSelectPrompt = "====================== Select a Park for Further Details ======================\n";

                string validSelectionError = "Please make a valid selection from the menu. Press Enter to try again.";

                string quitPrompt = $"{Command_Quit}) Quit\n";

                string selectionPrompt = "Selection:";

                int commandIfNum;

                Console.Clear();
                Console.SetCursorPosition((Console.WindowWidth - parkSelectPrompt.Length) / 2, Console.CursorTop);
                Console.WriteLine(parkSelectPrompt);

                ParkDAL      parkDAL  = new ParkDAL(DatabaseConnection);
                IList <Park> parkList = new List <Park>();
                parkList = parkDAL.GetParkList();

                foreach (Park park in parkList)
                {
                    Console.WriteLine($"{park.ParkID}) {park.Name}");
                }
                Console.WriteLine(quitPrompt);

                string command = CLIHelper.GetString(selectionPrompt).ToUpper();

                if (command == Command_Quit)
                {
                    return;
                }
                else if (!int.TryParse(command, out commandIfNum))
                {
                    Console.WriteLine(validSelectionError);
                    Console.ReadLine();
                    continue;
                }
                else
                {
                    bool commandNumIsInParkList = false;
                    foreach (Park park in parkList)
                    {
                        if (park.ParkID == commandIfNum)
                        {
                            commandNumIsInParkList = true;
                            break;
                        }
                    }

                    if (commandNumIsInParkList)
                    {
                        ParkInfoScreen(commandIfNum);
                    }
                    else
                    {
                        Console.WriteLine(validSelectionError);
                        Console.ReadLine();
                    }
                }
            }
        }
        private void DisplayParkInfo(Park selectedPark)
        {
            int dateRangeSelected = -1;
            int userInput         = 0;

            Console.WriteLine();
            Console.WriteLine("PARK INFORMATION SCREEN");
            Console.WriteLine();

            //access park info from database

            ParkDAL dal = new ParkDAL(DatabaseConnection);

            selectedPark = dal.DisplayParkInfo(selectedPark);

            Console.WriteLine(selectedPark.Name + " National Park");
            Console.WriteLine("State: " + selectedPark.State);
            Console.WriteLine("Established: " + selectedPark.EstablishYear);
            Console.WriteLine("Area: " + string.Format("{0:n0}", selectedPark.Area) + " sq km");
            Console.WriteLine("Annual Visitors: " + string.Format("{0:n0}", selectedPark.Vistors));
            Console.WriteLine();

            //word wrap for console display

            String[]      words  = selectedPark.Description.Split(' ');
            StringBuilder buffer = new StringBuilder();

            foreach (String word in words)
            {
                buffer.Append(word);

                if (buffer.Length >= Console.WindowWidth)
                {
                    String line = buffer.ToString().Substring(0, buffer.Length - word.Length);
                    Console.WriteLine(line);
                    buffer.Clear();
                    buffer.Append(word);
                }
                buffer.Append(" ");
            }
            Console.WriteLine(buffer.ToString());
            Console.WriteLine();
            Console.WriteLine("Select a Command:");
            Console.WriteLine("1) View Campgrounds in " + selectedPark.Name);
            Console.WriteLine("2) View Existing Reservations for the Next 30 Days");
            Console.WriteLine("3) Make a Reservation");
            Console.WriteLine("4) Return to Previous Screen");

            userInput = CLIHelper.GetInteger("");

            //user input implements corresponding method, default returns to ViewParksMenu()

            List <Campground> campgroundsInPark = new List <Campground>();

            switch (userInput)
            {
            case 1:
                ViewCampgrounds(selectedPark, campgroundsInPark);
                break;

            case 2:
                ViewUpcomingReservations(selectedPark);
                break;

            case 3:
                while (dateRangeSelected == -1)
                {
                    dateRangeSelected = ChooseCampground(selectedPark, campgroundsInPark, dateRangeSelected);
                }
                break;

            default:
                Console.WriteLine();
                break;
            }
        }
Exemple #22
0
        public bool ParkDisplay()
        {
            Console.Clear();
            ParkDAL     parkDAL = new ParkDAL(connectionString);
            List <Park> parks   = parkDAL.GetParks();

            Console.WriteLine("  __  __  ___  ______ __   ___   __  __  ___  __       ____   ___  ____  __ __  __");
            Console.WriteLine(@"  ||\ || // \\ | || | ||  // \\  ||\ || // \\ ||       || \\ // \\ || \\ || // (( \");
            Console.WriteLine(@"  ||\\|| ||=||   ||   || ((   )) ||\\|| ||=|| ||       ||_// ||=|| ||_// ||<<   \\ ");
            Console.WriteLine(@"  || \|| || ||   ||   ||  \\_//  || \|| || || ||__|    ||    || || || \\ || \\ \_))");
            Console.WriteLine();
            Console.WriteLine(@"  ........::::::::::::..           .......|...............::::::::........");
            Console.WriteLine(@"     .:::::; ; ; ; ; ; ; ; ; ; ;:::::.... .     \   | ../....::::; ; ; ;:::::..");
            Console.WriteLine(@"         .       ...........   / \\_   \  |  /     ......  .     ........./\");
            Console.WriteLine(@"...:::../\\_  ......     ..._/'   \\\_  \###/   /\_    .../ \_.......   _//");
            Console.WriteLine(@".::::./   \\\ _   .../\    /'      \\\\#######//   \/\   //   \_   ....////");
            Console.WriteLine(@"    _/      \\\\   _/ \\\ /  x       \\\\###////      \////     \__  _/////");
            Console.WriteLine(@"  ./   x       \\\/     \/ x X           \//////                   \/////");
            Console.WriteLine(@" /     XxX     \\/         XxX X                                    ////   x");
            Console.WriteLine(@"-----XxX-------------|-------XxX-----------*--------|---*-----|------------X--");
            Console.WriteLine(@"       X        _X      *    X      **         **             x   **    *  X");
            Console.WriteLine(@"      _X                    _X           x                *          x     X_");
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine(" *".PadRight(33, '*'));
            Console.WriteLine(" Select a Park for Further Details");
            Console.WriteLine(" *".PadRight(33, '*'));

            foreach (Park p in parks)
            {
                Console.WriteLine($" |{p.AlphaID}| {p.Name}");
            }
            Console.WriteLine(" |Q| Quit");

            string input = Console.ReadLine();

            if (input.ToLower() == "q")
            {
                return(false);
            }

            else
            {
                foreach (Park p in parks)
                {
                    if (input == p.AlphaID.ToString())
                    {
                        bool running = true;
                        while (running)
                        {
                            running = ParkInfoScreen(p);
                        }
                        return(true);
                    }
                }

                Console.WriteLine(" Please enter a valid park. Press any key to continue.");
                Console.ReadKey();
            }
            return(true);
        }