TraktPlugin.TraktCache.AddEpisodeToWatchHistory C# (CSharp) Méthode

AddEpisodeToWatchHistory() static private méthode

static private AddEpisodeToWatchHistory ( TraktShow show, TraktEpisode episode ) : void
show TraktPlugin.TraktAPI.DataStructures.TraktShow
episode TraktPlugin.TraktAPI.DataStructures.TraktEpisode
Résultat void
        internal static void AddEpisodeToWatchHistory(TraktShow show, TraktEpisode episode)
        {
            var watchedEpisodes = (_WatchedEpisodes ?? new List<EpisodeWatched>()).ToList();

            var existingWatchedEpisode = watchedEpisodes.FirstOrDefault(e => (((e.ShowId == show.Ids.Trakt) && e.ShowId != null) || ((e.ShowTvdbId == show.Ids.Tvdb) && e.ShowTvdbId != null)) &&
                                                                                e.Season == episode.Season &&
                                                                                e.Number == episode.Number);

            // if it exists already, increment the play count only
            if (existingWatchedEpisode != null)
            {
                existingWatchedEpisode.Plays++;
                existingWatchedEpisode.WatchedAt = DateTime.UtcNow.ToISO8601();
            }
            else
            {
                watchedEpisodes.Add(new EpisodeWatched
                {
                    Number = episode.Number,
                    Season = episode.Season,
                    ShowId = show.Ids.Trakt,
                    ShowImdbId = show.Ids.Imdb,
                    ShowTvdbId = show.Ids.Tvdb,
                    ShowTitle = show.Title,
                    ShowYear = show.Year,
                    Plays = 1,
                    WatchedAt = DateTime.UtcNow.ToISO8601()
                });
            }

            _WatchedEpisodes = watchedEpisodes;

            // now remove from watchlist and paused state since it will be removed from online in these cases
            RemoveEpisodeFromWatchlist(episode);
            RemoveEpisodeFromPausedData(show, episode);
            RemoveShowFromWatchlist(show);
        }
TraktCache