WeatherService.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using MediaBrowser.Common.Implementations.HttpServer;
  2. using MediaBrowser.Controller;
  3. using MediaBrowser.Model.Weather;
  4. using ServiceStack.ServiceHost;
  5. using System.Linq;
  6. using System.Threading;
  7. namespace MediaBrowser.Api
  8. {
  9. /// <summary>
  10. /// Class Weather
  11. /// </summary>
  12. [Route("/Weather", "GET")]
  13. public class GetWeather : IReturn<WeatherInfo>
  14. {
  15. /// <summary>
  16. /// Gets or sets the location.
  17. /// </summary>
  18. /// <value>The location.</value>
  19. public string Location { get; set; }
  20. }
  21. /// <summary>
  22. /// Class WeatherService
  23. /// </summary>
  24. public class WeatherService : BaseRestService
  25. {
  26. /// <summary>
  27. /// Gets the specified request.
  28. /// </summary>
  29. /// <param name="request">The request.</param>
  30. /// <returns>System.Object.</returns>
  31. public object Get(GetWeather request)
  32. {
  33. var result = Kernel.Instance.WeatherProviders.First().GetWeatherInfoAsync(request.Location, CancellationToken.None).Result;
  34. return ToOptimizedResult(result);
  35. }
  36. }
  37. }