public IActionResult Detail(string parkCode, ParkWeatherVM vm) //add temptype as a parameter
        {
            // Get the details of the specific park and pass it into the view model.
            vm.Park = parkDAO.GetParkByCode(parkCode);

            //Get the weather for that particular park and pass it into the view model.
            IList <Weather> weather = weatherDAO.GetWeather(parkCode);

            //Seperate today's forecast from the rest of the days and then order the rest of the list.
            weather    = vm.GetTodaysForecast(weather);
            vm.Weather = weather.OrderBy(w => w.FiveDayForecastValue).ToList();

            //session will be GET in here, probably put it in to view model

            if (HttpContext.Session.GetString("temperature") == null || HttpContext.Session.GetString("temperature") == "F")
            {
                vm.TempType = "F";
            }
            else
            {
                vm.TempType = HttpContext.Session.GetString("temperature");
                foreach (Weather w in weather)
                {
                    vm.Today.Low  = (int)w.ConvertTemp("C", w.Low);
                    vm.Today.High = (int)w.ConvertTemp("C", w.High);
                    w.Low         = (int)w.ConvertTemp("C", w.Low);
                    w.High        = (int)w.ConvertTemp("C", w.High);
                }
            }

            return(View(vm));
        }
Example #2
0
        public IActionResult Detail(string id)
        {
            Park             park      = parkDAO.GetParkByCode(id);
            IList <Forecast> forecasts = parkDAO.GetFiveDay(id);
            string           tempUnit  = GetPreferredUnit();

            return(View(new DetailViewModel(park, forecasts, tempUnit)));
        }