public ActionResult ParkDetail(string id) {//create an object from session and use its Unit property to pass to the GetPark method of ParkListSqlDAL ParkListModel existingSession = Session["whatUnit"] as ParkListModel; // char whatUnit = Session["whatUnit] as char; return(View("ParkDetail", parkDal.GetPark(id, existingSession.Unit))); } //parkDal.GetPark(id, whatUnit);
//GET: Home public ActionResult Index() {//if no session exists create one and set the initial unit to F if (Session["whatUnit"] == null) { Session["whatUnit"] = new ParkListModel(); //session ["whatUnit"] = 'f' ParkListModel existingSession = Session["whatUnit"] as ParkListModel; existingSession.Unit = 'F'; } return(View("Index", parkDal.GetAllParks())); }
//GET: Home public ActionResult Weather(string id, char unit) { ParkListModel existingSession = Session["whatUnit"] as ParkListModel; existingSession.Unit = unit; List <WeatherDayModel> forecast = weatherDal.GetWeather(id, existingSession.Unit); if (forecast == null || forecast.Count == 0) { return(HttpNotFound()); } return(View("Weather", forecast)); }