/// <summary> /// Returns detail view of Park with temperature stored in session data. /// </summary> /// <param name="code">Park Code</param> /// <param name="isFarenheit"> Defaults to 'true' from Home/index view. </param> /// <param name="isSwitch"> To determine if user is toggling temperature or switching page</param> /// <returns></returns> public IActionResult Detail(string code, bool isFarenheit, bool isSwitch = false) { Park parkDetail = parkDAO.GetById(code); IList <Weather> weathers = parkDAO.GetWeather(code); // See if the user has visited the page. Store in Session Data bool state = true; if (HttpContext.Session.GetString("test") == null) { //save true HttpContext.Session.SetString("test", state.ToString()); } else { state = Convert.ToBoolean(HttpContext.Session.GetString("test")); } //if toggling temperature >>>> change if (isSwitch) { if (state) { HttpContext.Session.SetString("test", "false"); } else { HttpContext.Session.SetString("test", "true"); } } bool a = Convert.ToBoolean(HttpContext.Session.GetString("test")); DetailViewModel dvm = new DetailViewModel(parkDetail, weathers, a); return(View(dvm)); }