/// <summary> /// Call the AccuWeather CurrentConditions API, method that gets actual wheather conditions /// </summary> /// <returns></returns> private async Task LoadCurrentConditions() { try { List <CurrentCondition> conditionsNow = await CurrentConditionsAPIHelper.CurrentConditionNow(ViewModel.Location.Key, true, CultureInfo.CurrentUICulture.Name); ViewModel.CurrentCondition = conditionsNow.FirstOrDefault(); } catch (AccuWeatherArgumentException ex) { // Could do a specific action for each of the erros, but didn´t have the time to do it. Sorry! LogError("LoadCurrentConditions", ex); } catch (AccuWeatherConfigurationException ex) { // Could do a specific action for each of the erros, but didn´t have the time to do it. Sorry! LogError("LoadCurrentConditions", ex); } catch (AccuWeatherException ex) { // Could do a specific action for each of the erros, but didn´t have the time to do it. Sorry! LogError("LoadCurrentConditions", ex); } catch (AccuWeatherFaultyRequestException ex) { // Could do a specific action for each of the erros, but didn´t have the time to do it. Sorry! LogError("LoadCurrentConditions", ex); } }
public HomeController(IConfiguration config, LocationAPIHelper locationAPIHelper, CurrentConditionsAPIHelper currentConditionsAPIHelper, ForecastAPIHelper forecastAPIHelper, ILogger <HomeController> logger) { ViewModel = new HomeViewModel(); _logger = logger; Configuration = config; LocationAPIHelper = locationAPIHelper; CurrentConditionsAPIHelper = currentConditionsAPIHelper; ForecastAPIHelper = forecastAPIHelper; }