Exemple #1
0
        /// <summary>
        /// Call the AccuWeather Locations API, method that gets the location based on lat and long
        /// </summary>
        /// <returns></returns>
        private async Task LoadLocation(double latitude, double longitude)
        {
            try
            {
                Location location = await LocationAPIHelper.GetLocation(latitude, longitude, CultureInfo.CurrentUICulture.Name);

                ViewModel.Location = location;
            }
            catch (AccuWeatherArgumentException ex)
            {
                // Could do a specific action for each of the erros, but didn´t have the time to do it. Sorry!
                LogError("LoadLocation", 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("LoadLocation", 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("LoadLocation", 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("LoadLocation", ex);
            }
        }
Exemple #2
0
        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;
        }