Esempio n. 1
0
        public IActionResult Index()
        {
            ParkSurveyVM vm = new ParkSurveyVM();

            vm.survey = new Survey();
            vm.parks  = parksDAO.GetAllParks();
            return(View(vm));
        }
        /// <summary>
        /// Runs menu to give user a choice of parks.
        /// </summary>
        public void RunParkCLI()
        {
            Console.Clear();
            PrintHeader();
            GetAllParks();
            PrintParkChoices();

            while (true)
            {
                string       userChoice = Console.ReadLine();
                IList <Park> parks      = parksDAO.GetAllParks();
                foreach (Park park in parks)
                {
                    string parkIdString = park.ParkId.ToString();
                    if (userChoice == parkIdString)
                    {
                        CampGroundCLI campGroundCLI = new CampGroundCLI(parksDAO, campgroundDAO, siteDAO, reservationDAO);
                        campGroundCLI.RunCampGroundCLI(park.Name, park.ParkId);
                    }
                    else
                    {
                        switch (userChoice.ToLower())
                        {
                        case "p":
                            Console.Clear();
                            RunMainMenuCLI();
                            break;

                        default:
                            Console.WriteLine("The command provided was not a valid command, please try again.", Color.OrangeRed);
                            break;
                        }
                    }
                }
            }
        }
        public IActionResult Index()
        {
            IList <Park> park = parksDAO.GetAllParks();

            return(View(park));
        }
        /// <summary>
        /// Runs menu to give user a choice of campgrounds from the choosen park.
        /// </summary>
        /// <param name="parkName"></param>
        /// <param name="parkId"></param>
        public void RunCampGroundCLI(string parkName, int parkId)
        {
            List <string> Wrap(string text, int margin)
            {
                int start = 0, end;
                var lines = new List <string>();

                text = Regex.Replace(text, @"\s", " ").Trim();

                while ((end = start + margin) < text.Length)
                {
                    while (text[end] != ' ' && end > start)
                    {
                        end -= 1;
                    }

                    if (end == start)
                    {
                        end = start + margin;
                    }

                    lines.Add(text.Substring(start, end - start));
                    start = end + 1;
                }

                if (start < text.Length)
                {
                    lines.Add(text.Substring(start));
                }

                return(lines);
            }

            IList <Park> parks = parksDAO.GetAllParks();

            foreach (Park park in parks)
            {
                List <string> decript = Wrap(park.Description, 155);
                foreach (string dp in decript)
                {
                    Console.WriteLine($"         {dp}");
                }
                Console.WriteLine();

                userParkId = parkId;
                IList <Park> pa = parksDAO.GetAllParks();
                parkName = "";
                string parkDecript = "";
                foreach (Park name in pa)
                {
                    if (name.ParkId == userParkId)
                    {
                        parkName    = name.Name;
                        parkDecript = name.Description;
                    }
                }
                Console.Clear();
                PrintHeader();
                Console.WriteLine();
                Console.WriteLine($"                                                                         {parkName}", Color.Yellow);
                Console.WriteLine("__________________________________________________________________________________________________________________________________________________________________________", Color.DimGray);
                Console.WriteLine();
                foreach (string dp in decript)
                {
                    Console.WriteLine($"         {dp}", Color.DarkKhaki);
                }
                Console.WriteLine();
                Console.WriteLine("__________________________________________________________________________________________________________________________________________________________________________", Color.DimGray);

                GetCampGroundList();
                PrintCampGroundChoices();

                while (true)
                {
                    string             userChoice  = Console.ReadLine();
                    IList <Campground> campgrounds = campgroundDAO.Search(userParkId);
                    foreach (Campground campground in campgrounds)
                    {
                        string cgIdString = campground.CampgroundId.ToString();
                        if (userChoice == cgIdString)
                        {
                            Console.WriteLine();
                            DateTime fromDate = CLIHelper.GetDateTime("Please Enter Arrival Date(YYYY-MM-DD): ");
                            DateTime toDate   = CLIHelper.GetDateTime("Please Enter Departure Date (YYYY-MM-DD): ");
                            SiteCLI  siteCLI  = new SiteCLI(parksDAO, campgroundDAO, siteDAO, reservationDAO);
                            siteCLI.RunSiteCLI(parkName, parkId, campground.CampgroundId, campground.Name, campground.DailyFee, fromDate, toDate);
                        }
                        else
                        {
                            switch (userChoice.ToLower())
                            {
                            case "p":
                                Console.Clear();
                                ParkCLI parkCLI = new ParkCLI(parksDAO, campgroundDAO, siteDAO, reservationDAO);
                                parkCLI.RunParkCLI();
                                break;

                            default:
                                Console.WriteLine("The command provided was not a valid command, please try again.", Color.Red);
                                break;
                            }
                        }
                    }
                }
            }
        }
 public IActionResult Index()
 {
     return(View(ParksDAO.GetAllParks()));
 }