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)); }
public IActionResult Detail(ParkWeatherVM vm) { string tempchoice = vm.TempChoice; HttpContext.Session.SetString("temp", tempchoice); return(RedirectToAction("Detail", vm)); }
public IActionResult Detail(string id, ParkWeatherVM vm) { vm.TempChoice = HttpContext.Session.GetString("temp"); if (vm.TempChoice == null) { vm.TempChoice = "Fahrenheit"; } vm.park = parksDAO.GetPark(id); vm.weather = weatherDAO.GetWeather(id); vm.weatherDays = weatherDAO.GetWeatherDays(id); return(View(vm)); }
public IActionResult Detail(string tempType, string parkCode, ParkWeatherVM vm) { HttpContext.Session.SetString("temperature", tempType); return(RedirectToAction("Detail", new { parkCode = parkCode, ParkWeatherVM = vm })); }