diff options
| author | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-20 20:33:05 -0500 |
|---|---|---|
| committer | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-20 20:33:05 -0500 |
| commit | 767cdc1f6f6a63ce997fc9476911e2c361f9d402 (patch) | |
| tree | 49add55976f895441167c66cfa95e5c7688d18ce /MediaBrowser.Api/WeatherService.cs | |
| parent | 845554722efaed872948a9e0f7202e3ef52f1b6e (diff) | |
Pushing missing changes
Diffstat (limited to 'MediaBrowser.Api/WeatherService.cs')
| -rw-r--r-- | MediaBrowser.Api/WeatherService.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/MediaBrowser.Api/WeatherService.cs b/MediaBrowser.Api/WeatherService.cs new file mode 100644 index 000000000..0c04f5ec0 --- /dev/null +++ b/MediaBrowser.Api/WeatherService.cs @@ -0,0 +1,46 @@ +using MediaBrowser.Common.Net; +using MediaBrowser.Controller; +using MediaBrowser.Model.Weather; +using ServiceStack.ServiceHost; +using System.ComponentModel.Composition; +using System.Linq; +using System.Threading; + +namespace MediaBrowser.Api +{ + /// <summary> + /// Class Weather + /// </summary> + [Route("/Weather", "GET")] + public class GetWeather : IReturn<WeatherInfo> + { + /// <summary> + /// Gets or sets the location. + /// </summary> + /// <value>The location.</value> + public string Location { get; set; } + } + + /// <summary> + /// Class WeatherService + /// </summary> + [Export(typeof(IRestfulService))] + public class WeatherService : BaseRestService + { + /// <summary> + /// Gets the specified request. + /// </summary> + /// <param name="request">The request.</param> + /// <returns>System.Object.</returns> + public object Get(GetWeather request) + { + var kernel = (Kernel) Kernel; + + var location = string.IsNullOrWhiteSpace(request.Location) ? kernel.Configuration.WeatherLocation : request.Location; + + var result = kernel.WeatherProviders.First().GetWeatherInfoAsync(location, CancellationToken.None).Result; + + return ToOptimizedResult(result); + } + } +} |
