Example #1
0
        // GET: Park/Details
        public ActionResult Details(string id)
        {
            ParkDetails model = new ParkDetails();

            model.Weather = dal2.GetForcast(id);
            model.Park    = dal.GetParkDetails(id);

            if (Session["TempUnit"] == null)
            {
                foreach (Weather weather in model.Weather)
                {
                    weather.Unit        = 'F';
                    weather.Farhrenheit = true;
                    Session["TempUnit"] = weather.Unit;
                }
            }
            else if ((char)Session["TempUnit"] == 'C')
            {
                Session["TempUnit"] = 'F';
                foreach (Weather weather in model.Weather)
                {
                    weather.Unit = 'F';
                    weather.TempConversion('F');
                    weather.Celcius     = true;
                    Session["TempUnit"] = weather.Unit;
                }
            }
            else
            {
                Session["TempUnit"] = 'C';
            }
            return(View("Details", model));
        }
        public IActionResult Detail(string parkCode)  // Show Park Detail (includes weather)
        {
            ParkDetailVM parkVM = new ParkDetailVM();

            parkVM.TempUnit = HttpContext.Session.GetString("tempUnit");
            if (parkVM.TempUnit == null)
            {
                parkVM.TempUnit = "F";
                HttpContext.Session.SetString("tempUnit", parkVM.TempUnit);
            }
            parkVM.Park    = parkDAO.GetParkDetails(parkCode);
            parkVM.Weather = weatherDAO.GetWeather(parkCode, parkVM.TempUnit);
            return(View(parkVM));
        }
Example #3
0
        public async Task <ActionResult> Details(string parkCode)
        {
            List <Weather> weather = new List <Weather>();
            var            park    = parkDAO.GetParkDetails(parkCode);

            //park.AddFiveDayForecast(parkDAO.FiveDayForecast(parkCode));*///change to set weathers from API

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://api.darksky.net/forecast/cc281da8c085e79794f92e309796533f/");

                //HTTP GET
                var responseTask = client.GetAsync(park.Latitude.ToString() + "," + park.Longitude.ToString() + "?exclude=currently,minutely,hourly,alerts,flags");
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    string content = await result.Content.ReadAsStringAsync();

                    var root = JsonConvert.DeserializeObject <Rootobject>(content);
                    for (int i = 0; i < 5; i++)
                    {
                        Weather w = new Weather();
                        w.FiveDayForecastValue = i + 1;
                        w.HighTemp             = root.daily.data[i].temperatureHigh;
                        w.LowTemp  = root.daily.data[i].temperatureLow;
                        w.Forecast = root.daily.data[i].icon;
                        weather.Add(w);
                    }
                }
            }
            park.AddFiveDayForecast(weather);

            bool farenheit = HttpContext.Session.Get <bool>("isF");

            if (HttpContext.Session.Keys.Contains("isF") == false)
            {
                HttpContext.Session.Set("isF", true);
            }
            foreach (Weather weathers in park.Forecast)
            {
                weathers.Farenheit = HttpContext.Session.Get <bool>("isF");
            }

            return(View(park));
        }
Example #4
0
        //Gets the park details for the park selected by the user
        private void GetParkDetails()
        {
            this.parkId = CliHelper.GetInteger("Please choose a park for more details: ");
            IList <Park> parks = parkDAO.GetParkDetails(this.parkId);

            Console.Clear();

            foreach (Park info in parks)
            {
                Console.WriteLine($"{info.name} National Park");
                Console.WriteLine($"Location: {info.location}");
                Console.WriteLine($"Established: {info.establish_date}");
                Console.WriteLine($"Area: {info.area:N0} sq km");
                Console.WriteLine($"Annual Visitors: {info.visitors:N0}");
                Console.WriteLine();
                Console.WriteLine($"{info.description}");
                Console.WriteLine();

                CampGroundMenu();
            }
        }
Example #5
0
        public IActionResult ParkDetail(string id, string scale)
        {
            if (scale == null)
            {
                scale = HttpContext.Session.GetString("scale");

                if (scale == null)
                {
                    scale = "f";
                }
            }
            else
            {
                HttpContext.Session.SetString("scale", scale);
            }

            ViewData["scale"] = scale;

            Park park = parkDao.GetParkDetails(id);

            park.Weathers = weatherDao.GetForecast(id);
            return(View(park));
        }