public IActionResult Detail(string code) { if (!HttpContext.Session.Keys.Contains("temp")) { HttpContext.Session.SetString("temp", "f"); } TempData["temp"] = HttpContext.Session.GetString("temp"); Park park = parkDAO.GetParkByParkCode(code); List <Weather> fiveDay = weatherDAO.GetForecast(code); DetailViewModel vm = new DetailViewModel(); vm.FiveDay = fiveDay; vm.forecasts = new List <Forecast>(); if (HttpContext.Session.GetString("temp") == "f") { vm.isFahrenheit = true; } else { vm.isFahrenheit = false; } vm.Park = park; return(View(vm)); }
public IActionResult Detail(string parkCode) { dynamic mymodel = new ExpandoObject(); if (HttpContext.Session.GetString("TemperatureUnit") == null) { HttpContext.Session.SetString("TemperatureUnit", "F"); } ViewBag.TemperatureUnit = HttpContext.Session.GetString("TemperatureUnit"); mymodel.Forecast = forecastDAO.GetWeatherByParkCode(parkCode); mymodel.Park = parkDAO.GetParkByParkCode(parkCode); return(View(mymodel)); }