private async Task GetCurrentWeather(float lat, float lon) { try { if (StateContainer.WeatherStatus.CurrentWeather != null && DateTime.Now < StateContainer.WeatherStatus.NextWeatherApiCall) { CurrentWeather = StateContainer.WeatherStatus.CurrentWeather; LastWeatherUpdate = StateContainer.WeatherStatus.LastUpdated; } else { if (useCity) { CurrentWeather = await OpenWeather.GetCurrentWeatherByCity(city, Units.ToString().ToLower()); } else { CurrentWeather = await OpenWeather.GetCurrentWeatherByCoords(lat, lon, Units.ToString().ToLower()); } LastWeatherUpdate = DateTime.Now; StateContainer.WeatherStatus.CurrentWeather = CurrentWeather; StateContainer.WeatherStatus.LastUpdated = LastWeatherUpdate; StateContainer.WeatherStatus.NextWeatherApiCall = LastWeatherUpdate.AddMinutes(tGertWeatherMinutes); } } catch (HttpRequestException ex) { unauthorized = ex.StatusCode == HttpStatusCode.Unauthorized; errorMessage = ex.Message; } catch (Exception ex) { errorMessage = ex.Message; } }