コード例 #1
0
        /// <summary>
        /// Sets menu options of List of parks
        /// </summary>
        protected override void SetMenuOptions()
        {
            List <Park> parks = parkDAO.GetParks();

            foreach (Park park in parks)
            {
                this.menuOptions.Add(park.Id.ToString(), park.Name);
            }
            this.menuOptions.Add("Q", "Quit");
        }
コード例 #2
0
        public IActionResult Index()
        {
            //Get a list of parks for the select list in the view.
            IList <Park>   parks = parkDAO.GetParks();
            SurveyResultVM vm    = new SurveyResultVM();

            vm.Parks = new SelectList(parks, "ParkCode", "ParkName");

            //Return the view.
            return(View(vm));
        }
コード例 #3
0
        protected override void SetMenuOptions()
        {
            List <Park> viewParks = parkDAO.GetParks();
            int         Count     = 1;

            foreach (Park park in viewParks)
            {
                menuOptions.Add(Count.ToString(), park.parkName);
                Count++;
            }
            this.menuOptions.Add("Q", "Quit program");
        }
コード例 #4
0
        protected override void SetMenuOptions()
        {
            List <Park> parks = ParkDAO.GetParks();

            foreach (Park park in parks)
            {
                menuOptions.Add(park.ParkID.ToString(), park.Name);
            }

            this.menuOptions.Add("B", "Back to Main Menu");
            this.quitKey = "B";
        }
コード例 #5
0
        public IActionResult GetParks()
        {
            //get parks from database as a list
            IList <Park> parks = parkDAO.GetParks();

            return(View(parks));
        }
コード例 #6
0
        public IActionResult Index()
        {
            //Get a list of all the parks and pass it into the view.
            IList <Park> parks = parkDAO.GetParks();

            return(View(parks));
        }
コード例 #7
0
        /// <summary>
        /// Park selection menu
        /// </summary>
        private void DisplayParkMenu()
        {
            var parks = _db.GetParks();
            Dictionary <int, ParkItem> menu = new Dictionary <int, ParkItem>();

            bool exit = false;

            while (!exit)
            {
                menu.Clear();
                Console.Clear();
                DisplayColored("Select a park for further details...");

                for (int i = 1; i <= parks.Count; i++)
                {
                    menu.Add(i, parks[i - 1]);
                    Console.WriteLine($" ({i}) {parks[i - 1].Name}");
                }
                Console.WriteLine(" (R) Reservation History");
                Console.WriteLine(" (L) Logout");
                Console.WriteLine();

                var selection = CLIHelper.GetString(Message_EnterSelection);

                if (selection.ToLower() == Option_Logout)
                {
                    _userMgr.LogoutUser();
                    exit = true;
                }
                else if (selection.ToLower() == Option_ReservationHistory)
                {
                    var reservations = _db.GetReservationsForUserId(_userMgr.User.Id);
                    DisplayReservationHistory(reservations);
                }
                else
                {
                    try
                    {
                        var parkSel = int.Parse(selection);
                        if (menu.ContainsKey(parkSel))
                        {
                            DisplayParkDetailsMenu(menu[parkSel]);
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }
                    catch (ExitToMainException)
                    {
                        // do nothing, this is the main menu
                    }
                    catch (Exception e)
                    {
                        CLIHelper.DisplayDebugInfo(e);
                        DisplayInvalidSelection();
                    }
                }
            }
        }
コード例 #8
0
        public IActionResult Index()
        {
            // get parks
            IList <Park> parks = parkDAO.GetParks();

            return(View(parks));
        }
コード例 #9
0
        public void TestGetParks()
        {
            List <Park> parks = _db.GetParks();

            Assert.AreEqual(10, parks.Count, "Number of parks do not match.");
            Assert.AreEqual(TEST_PARK_CODE, parks[0].ParkCode, "Park info does not match.");
        }
コード例 #10
0
ファイル: ProjectCLI.cs プロジェクト: jacobbulicek/TEProjects
        private void GetParks(int parkId)
        {
            IList <Park> parks = parkDAO.GetParks(newPark.Park_Id);

            if (parks.Count > 0)
            {
                foreach (Park park in parks)
                {
                    Console.WriteLine("Park Name: " + park.Name.ToString().PadRight(20));
                    Console.WriteLine("Location: " + park.Location.PadRight(15));
                    Console.WriteLine("Established: " + park.Establish_Date.ToString().PadRight(12));
                    Console.WriteLine("Area: " + park.Area.ToString().PadRight(8));
                    Console.WriteLine("Visitors: " + park.Visitors.ToString().PadRight(10));
                    Console.WriteLine();
                    Console.WriteLine("Description: " + park.Description.ToString().PadRight(10));
                    Console.WriteLine();
                }
                CampgroundMenu();
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
                Console.ReadLine();
            }
        }
コード例 #11
0
        /// <summary>
        /// Controls the Home Page view of the parks
        /// </summary>
        /// <param name="park">Passing in a paramter of Park</param>
        /// <returns>Returns a view of the Home Page of parks</returns>
        public IActionResult Park(Park park)
        {
            IList <Park> output = parkDAO.GetParks();

            park.AllParks = output;
            return(View(park));
        }
コード例 #12
0
ファイル: ViewParksMenu.cs プロジェクト: pattm0824/Main
        //Constructor to call in IDAO, Generate List using GetParks(), and Create our menu with parks list
        public ViewParksMenu(IParkDAO parkdao, ICampgroundDAO campgroundDAO, IReservationDAO reservationDAO, ISiteDAO siteDAO) : base()
        {
            this.parkdao        = parkdao;
            this.campgroundDAO  = campgroundDAO;
            this.reservationDAO = reservationDAO;
            this.siteDAO        = siteDAO;

            //parkdao, campgroundDAO, reservationDAO, siteDAO,

            try
            {
                parkList = parkdao.GetParks();

                this.Title = "****View Parks****";
                for (int i = 0; i < parkList.Count; i++)
                {
                    this.menuOptions.Add($"{i + 1}", $"{parkList[i].Name}");
                }
                this.menuOptions.Add("Q", "Quit");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"There was an error: {ex.Message}");
            }
        }
        public IActionResult Index()
        {
            IList <Park> parks = dao.GetParks();

            ViewData["parks"] = parks;
            return(View());
        }
        public IActionResult Index(Park park)
        {
            IList <Park> parks = parkDAO.GetParks();

            park.Parks = parks;

            return(View(parks));
        }
コード例 #15
0
        //Gets the list of parks and displays them for the user to select
        private void GetParks()
        {
            IList <Park> parks = parkDAO.GetParks();

            foreach (Park park in parks)
            {
                Console.WriteLine($"{park.park_id.ToString()}) - {park.name.PadLeft(5)}");
            }
        }
コード例 #16
0
        public void ListParks()
        {
            IList <Park> parks = ParkDAO.GetParks();

            foreach (Park park in parks)
            {
                Console.WriteLine($"{park.Park_Id}) {park.Name}");
            }
        }
コード例 #17
0
        private void ListAllParks()
        {
            IList <Park> parks = parkDAO.GetParks();

            if (parks.Count > 0)
            {
                foreach (Park park in parks)
                {
                    Console.WriteLine($"Park ID\tPark Name");
                    Console.WriteLine($"{park.ParkId}\t{park.Name} National Park");
                    Console.WriteLine();
                }
            }
            else
            {
                Console.WriteLine("*****No Results*****");
            }
        }
コード例 #18
0
 public ParksMenu(IParkDAO parkDAO, ICampgroundDAO campgroundDAO, IReservationDAO reservationDAO, ISiteDAO siteDAO) : base(parkDAO, campgroundDAO, reservationDAO, siteDAO)
 {
     this.Title = "List of park names";
     parks      = parkDAO.GetParks();
     for (int i = 0; i < parks.Count; i++)
     {
         this.menuOptions.Add($"{i + 1}", $"{parks[i].Name}");
     }
     this.menuOptions.Add("Q", "Quit");
 }
コード例 #19
0
        public IActionResult Survey()
        {
            string surveyStatus = HttpContext.Session.GetString("SurveyStatus");

            ViewBag.SurveyStatus = surveyStatus;
            ViewBag.Parks        = parkDAO.GetParks();
            ViewBag.States       = states;

            return(View());
        }
コード例 #20
0
        private void DisplayParks()
        {
            IList <Parks> parks = parkDAO.GetParks();

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


            for (int index = 0; index < parks.Count; index++)
            {
                Console.WriteLine($"{parks[index].ParkName} National Park");
                Console.WriteLine($"Location:        {parks[index].Location}");
                Console.WriteLine($"Established:     {parks[index].EstablishedDate.ToString("yyyy/MM/dd")}");
                Console.WriteLine($"Area:            {parks[index].Area} sq km");
                Console.WriteLine($"Annual Visitors: {parks[index].Visitors}");
                Console.WriteLine();
                Console.WriteLine($"{parks[index].Description}");
                menuSpacer();
            }
        }
コード例 #21
0
        public IActionResult Results()
        {
            IList <Survey> SurveyResults = surveyDAO.GetSurveyResults();
            ResultsView    surveyModel   = new ResultsView()
            {
                AllSurveys = surveyDAO.GetSurveyResults(),
                AllParks   = parkDAO.GetParks(),
            };

            return(View(surveyModel));
            //REMOVED "RESULTS" FROM THE RETURN VIEW STATEMENT
        }
コード例 #22
0
        public void TestPark()
        {
            var park = CreatePark("Mt. Airy");

            var parks = _db.GetParks();

            park.Id = _db.AddPark(park);
            var newParks = _db.GetParks();

            Assert.AreEqual(parks.Count + 1, newParks.Count);

            bool foundPark = false;

            foreach (var newPark in newParks)
            {
                if (newPark.Id == park.Id)
                {
                    foundPark = true;
                }
            }
            Assert.IsTrue(foundPark);
        }
コード例 #23
0
        private void GetParks()
        {
            IList <Park> parks = parkDAO.GetParks();

            if (parks.Count > 0)
            {
                foreach (Park park in parks)
                {
                    Console.WriteLine(park.ParkID.ToString().PadRight(10).PadLeft(5) + park.Name.PadRight(40));
                }
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
            }
        }
コード例 #24
0
        public void ViewParks()
        {
            bool done = false;

            Console.WriteLine("Select a Park for Further Details:");
            Console.WriteLine();
            Console.WriteLine("──▒▒▒▒▒▒▒▒───▒▒▒▒▒▒▒▒───▒▒▒▒▒▒▒▒──");
            Console.WriteLine("─▒▐▒▐▒▒▒▒▌▒─▒▒▌▒▒▐▒▒▌▒─▒▒▌▒▒▐▒▒▌▒─");
            Console.WriteLine("──▒▀▄█▒▄▀▒───▒▀▄▒▌▄▀▒───▒▀▄▒▌▄▀▒──");
            Console.WriteLine("─────██─────────██─────────██─────");
            Console.WriteLine("░░░▄▄██▄░░░░░░░▄██▄░░░░░░░▄██▄░░░░");
            Console.WriteLine();


            while (!done)
            {
                IList <Park> parks = parkDAO.GetParks();
                int          count = parks.Count;

                for (int i = 0; i < parks.Count; i++)
                {
                    Console.WriteLine($"{i + 1}) {parks[i].Name}");
                }

                Console.WriteLine("Q) quit");
                Console.WriteLine();

                string select = Console.ReadLine().ToLower();
                Console.WriteLine();

                if (select == "q")
                {
                    Environment.Exit(1);
                }

                int.TryParse(select, out selectedParkId);
                done = helper.ParkMenuSelectValid(selectedParkId, count);
            }

            ParkDescription();
        }
コード例 #25
0
        /// <summary>
        /// Runs the main menu
        /// </summary>
        public override void Run()
        {
            IList <Park> parks = parkDAO.GetParks();

            MainMenuHeader(parks);

            while (true)
            {
                string input       = GetString("Make selection here: ");
                bool   isValidPark = false;


                if (int.TryParse(input, out int choice))
                {
                    choice--;

                    isValidPark = IsVaildPark(choice, parks);

                    if (isValidPark)
                    {
                        ParkCLI parkMenu = new ParkCLI(parks[choice], campgroundDAO, siteDAO, reservationDAO);
                        parkMenu.Run();
                        MainMenuHeader(parks);
                    }
                    else
                    {
                        // TODO write code for failed vaildation
                        Console.WriteLine($"{input} is Not a vaild park, please try again");
                        Console.CursorTop -= returnToInputLine;
                    }
                }
                else if (input.ToLower() == "q")
                {
                    break;
                }
                else
                {
                    InvalidInput();
                }
            }
        }
コード例 #26
0
ファイル: ViewParksMenu.cs プロジェクト: pattm0824/Main
        /// <summary>
        /// The override of ExecuteSelection handles whatever selection was made by the user.
        /// This is where any business logic is executed.
        /// </summary>
        /// <param name="choice">"Key" of the user's menu selection</param>
        /// <returns></returns>
        protected override bool ExecuteSelection(string choice)
        {
            parkList = parkdao.GetParks();
            switch (choice)
            {
            case "1":
                ParkInformationMenu parkInfoMenu = new ParkInformationMenu(parkdao, campgroundDAO, reservationDAO, siteDAO, parkList[0]);
                parkInfoMenu.Run();
                return(true);

            case "2":
                parkInfoMenu = new ParkInformationMenu(parkdao, campgroundDAO, reservationDAO, siteDAO, parkList[1]);
                parkInfoMenu.Run();
                return(true);

            case "3":
                parkInfoMenu = new ParkInformationMenu(parkdao, campgroundDAO, reservationDAO, siteDAO, parkList[2]);
                parkInfoMenu.Run();
                return(true);
            }
            return(true);
        }
コード例 #27
0
        protected override void BeforeDisplayMenu()
        {
            List <Park> parks = ParkDAO.GetParks();

            Park chosenPark = null;

            foreach (Park park in parks)
            {
                if (park.ParkID == chosen)
                {
                    chosenPark = park;
                }
            }

            PrintHeader();
            //Finish adding info with cw's
            Console.WriteLine($"Name: {chosenPark.Name}");
            Console.WriteLine($"Location: {chosenPark.Location}");
            Console.WriteLine($"Establised: {chosenPark.EstablishDateString}");
            Console.WriteLine($"Area: {chosenPark.Area} sq. km.");
            Console.WriteLine($"Annual Visitors: {chosenPark.Visitors}");
            Console.WriteLine("");
            Console.WriteLine(chosenPark.Description);
        }
コード例 #28
0
        /// <summary>
        /// Main CLI (View Parks Interface)
        /// </summary>
        public void RunCLI()
        {
            IList <Park> parks          = parkDAO.GetParks();
            bool         invalidCommand = false;

            while (true)
            {
                Console.Clear();

                PrintParksHeader();
                PrintParksMenu(parks);

                invalidCommand = PrintInvalidCommand(invalidCommand);
                string command  = Console.ReadLine().ToLower().Trim();
                bool   validInt = Int32.TryParse(command, out int parkSelection);

                if (validInt && parkSelection >= 1 && parkSelection <= parks.Count)
                {
                    RunParkInfoCLI(parks[parkSelection - 1]);
                }
                else
                {
                    switch (command)
                    {
                    case Command_Parks_Quit:
                        Console.Clear();
                        Console.WriteLine("Thank you for using the National Park Campsite Reservation System!\n");
                        return;

                    default:
                        invalidCommand = true;
                        break;
                    }
                }
            }
        }
コード例 #29
0
        public IActionResult GetParks()
        {
            IList <Park> parks = parkDAO.GetParks();

            return(View(parks));
        }
コード例 #30
0
        public IActionResult Index()
        {
            SurveyViewModel vm    = new SurveyViewModel();
            IList <Park>    Parks = parkDAO.GetParks();

            vm.ParkList = new SelectList(Parks, "ParkCode", "ParkName");

            var State = new List <SelectListItem> {
                new SelectListItem {
                    Text = "Alabama"
                },
                new SelectListItem {
                    Text = "Alaska"
                },
                new SelectListItem {
                    Text = "Arizona"
                },
                new SelectListItem {
                    Text = "Arkansas"
                },
                new SelectListItem {
                    Text = "California"
                },
                new SelectListItem {
                    Text = "Colorado"
                },
                new SelectListItem {
                    Text = "Connecticut"
                },
                new SelectListItem {
                    Text = "Delaware"
                },
                new SelectListItem {
                    Text = "Florida"
                },
                new SelectListItem {
                    Text = "Georgia"
                },
                new SelectListItem {
                    Text = "Hawaii"
                },
                new SelectListItem {
                    Text = "Idaho"
                },
                new SelectListItem {
                    Text = "Illinois"
                },
                new SelectListItem {
                    Text = "Indiana"
                },
                new SelectListItem {
                    Text = "Iowa"
                },
                new SelectListItem {
                    Text = "Kansas"
                },
                new SelectListItem {
                    Text = "Kentucky"
                },
                new SelectListItem {
                    Text = "Louisiana"
                },
                new SelectListItem {
                    Text = "Maine"
                },
                new SelectListItem {
                    Text = "Maryland"
                },
                new SelectListItem {
                    Text = "Massachusetts"
                },
                new SelectListItem {
                    Text = "Michigan"
                },
                new SelectListItem {
                    Text = "Minnesota"
                },
                new SelectListItem {
                    Text = "Mississippi"
                },
                new SelectListItem {
                    Text = "Missouri"
                },
                new SelectListItem {
                    Text = "Montana"
                },
                new SelectListItem {
                    Text = "North Carolina"
                },
                new SelectListItem {
                    Text = "North Dakota"
                },
                new SelectListItem {
                    Text = "Nebraska"
                },
                new SelectListItem {
                    Text = "Nevada"
                },
                new SelectListItem {
                    Text = "New Hampshire"
                },
                new SelectListItem {
                    Text = "New Jersey"
                },
                new SelectListItem {
                    Text = "New Mexico"
                },
                new SelectListItem {
                    Text = "New York"
                },
                new SelectListItem {
                    Text = "Ohio"
                },
                new SelectListItem {
                    Text = "Oklahoma"
                },
                new SelectListItem {
                    Text = "Oregon"
                },
                new SelectListItem {
                    Text = "Pennsylvania"
                },
                new SelectListItem {
                    Text = "Rhode Island"
                },
                new SelectListItem {
                    Text = "South Carolina"
                },
                new SelectListItem {
                    Text = "South Dakota"
                },
                new SelectListItem {
                    Text = "Tennessee"
                },
                new SelectListItem {
                    Text = "Texas"
                },
                new SelectListItem {
                    Text = "Utah"
                },
                new SelectListItem {
                    Text = "Vermont"
                },
                new SelectListItem {
                    Text = "Virginia"
                },
                new SelectListItem {
                    Text = "Washington"
                },
                new SelectListItem {
                    Text = "West Virginia"
                },
                new SelectListItem {
                    Text = "Wisconsin"
                },
                new SelectListItem {
                    Text = "Wyoming"
                }
            };

            vm.StateList = new SelectList(State, "Text", "Text");

            return(View(vm));
        }