Exemple #1
0
        public async Task <Forecast> GetForecastAsync(string city, WeatherUnit unit = WeatherUnit.Metric)
        {
            if (_ratelimiter.IsRatelimited(nameof(WeatherApiService)))
            {
                return(null);
            }

            try
            {
                return(await _api.GetForecastAsync(city, unit.ToString().ToLower(), _apiKey));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString());
            }
            return(null);
        }
Exemple #2
0
 public async Task <WeatherForecast> Query([FromQuery(Name = "city")] string city)
 {
     return(await _weatherApi.GetForecastAsync(city));
 }