예제 #1
0
        //action to get Weather details of a City
        //I used the method from iAsset.WeatherViewer.Core.OpenWeatherMapService class
        public ActionResult GetCityWeather(string cName)
        {
            try
            {
                if (cName == null)
                {
                    throw (new Exception("City Name is not given"));
                }

                OpenWeatherMapService svc = new OpenWeatherMapService();
                var response = svc.GetCityWeather(cName);

                if (response != null)
                {
                    return(Json(response, JsonRequestBehavior.AllowGet));
                }

                throw (new Exception("No Response from OpenWeatherMapService"));
            }
            catch (Exception ex)
            {
                return(ThrowJsonError(ex));
            }
        }