Exemplo n.º 1
0
        public async Task DeleteLocalFilms()
        {
            if (!await _storageService.FileExistsAsync(FilmCacheFile))
            {
                return;
            }

            await _storageService.DeleteFileAsync(FilmCacheFile);

            _filmCache.ClearCache(FilmCacheFile);
        }
Exemplo n.º 2
0
        private async Task <List <Cinema> > LoadCinemasFromFileOrApi()
        {
            if (!await _storageService.FileExistsAsync(CinemaCacheFile))
            {
                var cinemas = await _apiClient.GetCinemas();

                var json = JsonConvert.SerializeObject(cinemas);
                await _storageService.WriteAllTextAsync(CinemaCacheFile, json);

                return(cinemas);
            }

            var fileContents = await _storageService.ReadAllTextAsync(CinemaCacheFile);

            var cinemaList = JsonConvert.DeserializeObject <List <Cinema> >(fileContents);

            return(cinemaList ?? new List <Cinema>());
        }