예제 #1
0
        public IActionResult Detail(string parkCode)
        {
            Park            park    = parkDal.GetPark(parkCode);
            IList <Weather> weather = weatherDal.GetWeatherByPark(parkCode);

            //send in a temperature scale?
            //get tempScale (default or via SetTempScale)
            //I feel like I'm not actually using the session b/c I'm saving it as a value in the model.
            string tempScale = HttpContext.Session.GetString("tempScale");

            //if not set yet
            if (tempScale == null)
            {
                tempScale = "F";
                HttpContext.Session.SetString("tempScale", tempScale); //this defaults the weather to Fahrenheit scale (could base on location?)
            }
            //if set to fahrenheit **FROM** celcius
            else if (tempScale == "tempF")
            {
                tempScale = "F"; //set tempscale to F (for detail page weather report) if fahrenheit is chosen by button
            }
            //if set to celcius from fahrenheit
            else
            {
                tempScale = "C"; //set tempscale to C (for detail page weather report) if fahrenheit is chosen by button
            }

            DetailViewModel dvm = new DetailViewModel(park, weather);

            dvm.TempScale = tempScale; //load the detailViewModel with our tempscale.
            return(View(dvm));
        }
예제 #2
0
        public IActionResult Detail(string id)
        {
            ParkModel model = _parkDAL.GetPark(id);

            model.Weather = _weatherDAL.GetWeatherByPark(id);
            model.TemperatureScaleModel = new TemperatureScaleModel();

            if (HttpContext.Session.Get <TemperatureScaleModel>("TemperatureType") != null)
            {
                model.TemperatureScaleModel.TemperatureScale = HttpContext.Session.Get <TemperatureScaleModel>("TemperatureType").TemperatureScale.ToString();
            }

            return(View(model));
        }