Example #1
0
        /// <summary>
        /// Returns detailed season information for a single <see cref="TvMazeSeries"/> with given <paramref name="id"/>. This method caches request
        /// to same series using the cache path given in <see cref="TvMazeApiV1"/> constructor.
        /// </summary>
        /// <param name="id">TvMaze id of series</param>
        /// <returns>Season information</returns>
        public async Task <List <TvMazeSeason> > GetSeriesSeasonsAsync(int id, bool cacheOnly)
        {
            string cache = CreateAndGetCacheName(id, "Seasons");
            TvMazeSeriesSeasonSearch returnValue = null;

            if (!string.IsNullOrEmpty(cache) && File.Exists(cache))
            {
                returnValue = await _downloader.ReadCacheAsync <TvMazeSeriesSeasonSearch>(cache).ConfigureAwait(false);
            }
            else
            {
                if (cacheOnly)
                {
                    return(null);
                }
                string url = GetUrl(URL_GETSEASONS, id);
                returnValue = await _downloader.DownloadAsync <TvMazeSeriesSeasonSearch>(url, cache).ConfigureAwait(false);
            }
            return(returnValue.Results);
        }
        /// <summary>
        /// Returns detailed season information for a single <see cref="TvMazeSeries"/> with given <paramref name="id"/>. This method caches request
        /// to same series using the cache path given in <see cref="TvMazeApiV1"/> constructor.
        /// </summary>
        /// <param name="id">TvMaze id of series</param>
        /// <returns>Season information</returns>
        public List <TvMazeSeason> GetSeriesSeasons(int id, bool cacheOnly)
        {
            string cache = CreateAndGetCacheName(id, "Seasons");
            TvMazeSeriesSeasonSearch returnValue = null;

            if (!string.IsNullOrEmpty(cache) && File.Exists(cache))
            {
                returnValue = _downloader.ReadCache <TvMazeSeriesSeasonSearch>(cache);
            }
            else
            {
                if (cacheOnly)
                {
                    return(null);
                }
                string url = GetUrl(URL_GETSEASONS, id);
                returnValue = _downloader.Download <TvMazeSeriesSeasonSearch>(url, cache);
            }
            if (returnValue.Results == null)
            {
                return(null);
            }
            return(returnValue.Results);
        }