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

AddMovieToWatchHistory() static private méthode

static private AddMovieToWatchHistory ( TraktMovie movie ) : void
movie TraktPlugin.TraktAPI.DataStructures.TraktMovie
Résultat void
        internal static void AddMovieToWatchHistory(TraktMovie movie)
        {
            var watchedMovies = (_WatchedMovies ?? new List<TraktMovieWatched>()).ToList();

            var existingWatchedMovie = watchedMovies.FirstOrDefault(m => ((m.Movie.Ids.Trakt == movie.Ids.Trakt) && movie.Ids.Trakt != null) ||
                                                                         ((m.Movie.Ids.Imdb == movie.Ids.Imdb) && movie.Ids.Imdb.ToNullIfEmpty() != null) ||
                                                                         ((m.Movie.Ids.Tmdb == movie.Ids.Tmdb) && movie.Ids.Tmdb != null));

            // if it exists already, increment the play count only
            if (existingWatchedMovie != null)
            {
                existingWatchedMovie.Plays++;
                existingWatchedMovie.LastWatchedAt = DateTime.UtcNow.ToISO8601();
            }
            else
            {
                watchedMovies.Add(new TraktMovieWatched
                {
                    LastWatchedAt = DateTime.UtcNow.ToISO8601(),
                    Movie = new TraktMovie
                    {
                        Ids = movie.Ids,
                        Title = movie.Title,
                        Year = movie.Year
                    },
                    Plays = 1
                });
            }

            _WatchedMovies = watchedMovies;

            // now remove from watchlist and paused state since it will be removed from online in these cases
            RemoveMovieFromWatchlist(movie);
            RemoveMovieFromPausedData(movie);
        }
TraktCache