Пример #1
0
        public async Task <ObservableCollection <Planet> > GetAllPlanetsAsync(bool refresh = false)
        {
            if (refresh)
            {
                _currentPlanets.Clear();
                await LoadDataAndSaveFileAsync();
            }
            else if (!_currentPlanets.HasItems())
            {
                var file = await _localStorageService.ReadStringFromStorageAsync("planets");

                if (file.IsNeitherNullNorEmpty())
                {
                    var planets = JsonConvert.DeserializeObject <ObservableCollection <Planet> >(file);
                    _currentPlanets.AddRange(planets);
                }
                else
                {
                    await LoadDataAndSaveFileAsync();
                }
            }
            return(_currentPlanets);
        }