Ejemplo n.º 1
0
        /// <summary>
        /// Gets the WeatherResponse object from the WeatherApi wrapper and returns a view
        /// </summary>
        /// <returns>View to display weather</returns>
        public ActionResult Index()
        {
            var weatherApi = new WeatherApi();
            var weather    = weatherApi.getWeather("30.4704", "-87.2329");

            return(View(weather));
        }
        /// <summary>
        /// Gets WeatherApiResponse object and returns it as a json object
        /// </summary>
        /// <returns>Json object in HttpResponseMessage</returns>
        public HttpResponseMessage Get()
        {
            var weather    = new WeatherApi();
            var serializer = new JavaScriptSerializer();
            var json       = serializer.Serialize(weather.getWeather("30.4704", "-87.2329"));

            return(new HttpResponseMessage()
            {
                Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json")
            });
        }