Esempio n. 1
0
        private async Task LoadDataAsync()
        {
            var currentLocationTask = _locationService.GetCurrentLocationAsync();
            var favoriteCitiesTask  = _favoritesService.GetFavoriteCitiesAsync();

            await Task.WhenAll(currentLocationTask, favoriteCitiesTask).ConfigureAwait(false);

            var currentLocation = currentLocationTask.Result;
            var favoriteCities  = favoriteCitiesTask.Result;

            var requests = new ObservableCollection <WeatherRequest>(favoriteCities.Select(c => new WeatherRequest
            {
                City = c
            }));

            if (currentLocation != null)
            {
                var lwr = new LocationWeatherRequest
                {
                    City = new City {
                        Name = "Loading..."
                    }
                };

                requests.Insert(0, lwr);
                GetCurrentLocationWeather(currentLocation);
            }

            WeatherRequests = requests;

            ReloadAction?.Invoke();
        }