示例#1
0
        // It is actually importing all episodes - seasons are already imported with series
        private async Task ImportSeasonDetails()
        {
            for (var index = 0; index < _importSeasonsIds.Count; index++)
            {
                var seasonWithSeries = _importSeasonsIds.ElementAt(index);

                var seasonDetailsJson = await _movieDbApi.GetSeason(seasonWithSeries.MovieDbSeriesId, seasonWithSeries.SeasonNumber);

                if (seasonDetailsJson != null)
                {
                    var episodes = _movieDbDomainConverter.ConvertToEpisode(seasonDetailsJson, seasonWithSeries.SeasonId);

                    foreach (var episodeFromImport in episodes)
                    {
                        var episodeFromDb = await _tvSeriesContext
                                            .Episodes
                                            .Where(x => x.MovieDbId == episodeFromImport.MovieDbId)
                                            .FirstOrDefaultAsync();

                        await _movieDbImportServiceDbHelper.AddOrUpdate(episodeFromDb, episodeFromImport);
                    }
                }
                else
                {
                    _logger.LogInformation("Season with SeriesId [{0}] and SeasonId [{1}] not found", seasonWithSeries.SeriesId, seasonWithSeries.SeasonId);
                }
            }
        }