Beispiel #1
0
        private async void LoadEpisode()
        {
            if (!LoadingActive)
            {
                LoadingActive = true;
                String id;
                String season;
                String episodeNr;
                NavigationContext.QueryString.TryGetValue("id", out id);
                NavigationContext.QueryString.TryGetValue("season", out season);
                NavigationContext.QueryString.TryGetValue("episode", out episodeNr);

                LayoutRoot.Opacity = 1;

                show = await showController.getShowByTVDBID(id);

                episode = await episodeController.getEpisodeByTvdbAndSeasonInfo(id, season, episodeNr, show);

                if (episode != null)
                {
                    DateTime airTime = new DateTime(1970, 1, 1, 0, 0, 9, DateTimeKind.Utc);
                    airTime = airTime.AddSeconds(episode.FirstAired);

                    int daysSinceRelease = (DateTime.Now - airTime).Days;

                    App.EpisodeViewModel.UpdateEpisodeView(episode, show);
                    App.EpisodeViewModel.IsDataLoaded = true;
                    LoadBackgroundImage(show);
                    LoadScreenImage(episode);

                    InitAppBar();
                }
                LoadingActive = false;
            }
        }
Beispiel #2
0
        private void CreateOrSetShow(TraktShow show, IEnumerable <TraktSyncCollectionPostShowSeason> showSeasons,
                                     TraktMetadata metadata = null, DateTime?collectedAt = null)
        {
            var existingShow = _collectionPost.Shows.Where(s => s.Ids == show.Ids).FirstOrDefault();

            if (existingShow != null)
            {
                existingShow.Seasons = showSeasons;
            }
            else
            {
                var collectionShow = new TraktSyncCollectionPostShow();
                collectionShow.Ids   = show.Ids;
                collectionShow.Title = show.Title;
                collectionShow.Year  = show.Year;

                if (metadata != null)
                {
                    collectionShow.Metadata = metadata;
                }

                if (collectedAt.HasValue)
                {
                    collectionShow.CollectedAt = collectedAt.Value.ToUniversalTime();
                }

                collectionShow.Seasons = showSeasons;
                (_collectionPost.Shows as List <TraktSyncCollectionPostShow>).Add(collectionShow);
            }
        }
Beispiel #3
0
        public TraktScrobbleModule_Tests()
        {
            Movie = new TraktMovie
            {
                Title = "Guardians of the Galaxy",
                Year  = 2014,
                Ids   = new TraktMovieIds
                {
                    Trakt = 28,
                    Slug  = "guardians-of-the-galaxy-2014",
                    Imdb  = "tt2015381",
                    Tmdb  = 118340
                }
            };

            Show = new TraktShow
            {
                Title = "Breaking Bad"
            };

            Episode = new TraktEpisode
            {
                SeasonNumber = 1,
                Number       = 1,
                Ids          = new TraktEpisodeIds
                {
                    Trakt  = 16,
                    Tvdb   = 349232,
                    Imdb   = "tt0959621",
                    Tmdb   = 62085,
                    TvRage = 637041
                }
            };
        }
Beispiel #4
0
        /// <summary>Adds a <see cref="TraktShow" />, which will be added to the history remove post.</summary>
        /// <param name="show">The Trakt show, which will be added.</param>
        /// <returns>The current <see cref="TraktSyncHistoryRemovePostBuilder" /> instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown, if the given show is null.
        /// Thrown, if the given show ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown, if the given show has no valid ids set.
        /// Thrown, if the given show has an year set, which has more or less than four digits.
        /// </exception>
        public TraktSyncHistoryRemovePostBuilder AddShow(TraktShow show)
        {
            ValidateShow(show);
            EnsureShowsListExists();

            return(AddShowOrIgnore(show));
        }
Beispiel #5
0
        private async void CheckinEpisode_Click(object sender, RoutedEventArgs e)
        {
            this.progressBarLoading.Visibility = System.Windows.Visibility.Visible;
            lastModel = (ListItemViewModel)((MenuItem)sender).DataContext;
            App.TrackEvent("ViewShow", "Checkin context");

            if (await episodeController.checkinEpisode(lastModel.Tvdb, App.ShowViewModel.Name, Int16.Parse(App.ShowViewModel.Year), lastModel.Season, lastModel.Episode))
            {
                lastModel.Watched = true;
                TraktShow show = await showController.getShowByTVDBID(lastModel.Tvdb);

                try
                {
                    App.MainPage.ShowWatchingNowShow(await episodeController.getEpisodeByTvdbAndSeasonInfo(lastModel.Tvdb, lastModel.Season, lastModel.Episode, show), show, DateTime.UtcNow);
                }
                catch (NullReferenceException) { }
                ToastNotification.ShowToast("Show", "Checked in!");
            }
            else
            {
                ErrorManager.ShowConnectionErrorPopup();
            }

            lastModel = null;
            this.progressBarLoading.Visibility = System.Windows.Visibility.Collapsed;
        }
Beispiel #6
0
        private void Validate(TraktEpisode episode, TraktShow show)
        {
            if (episode == null)
            {
                throw new ArgumentNullException(nameof(episode), "episode must not be null");
            }

            if (episode.SeasonNumber < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(episode.SeasonNumber), "episode season number not valid");
            }

            if (episode.Number < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(episode.Number), "episode number not valid");
            }

            if (show == null)
            {
                throw new ArgumentNullException(nameof(show), "show must not be null");
            }

            if (string.IsNullOrEmpty(show.Title))
            {
                throw new ArgumentException("show title not valid", nameof(show.Title));
            }
        }
        private void Validate(TraktEpisode episode, TraktShow show)
        {
            if (episode == null)
            {
                throw new ArgumentNullException(nameof(episode), "episode must not be null");
            }

            if (episode.Ids == null || !episode.Ids.HasAnyId)
            {
                if (show == null)
                {
                    throw new ArgumentNullException(nameof(show), "episode ids not set or have no valid id - show must not be null");
                }

                if (string.IsNullOrEmpty(show.Title))
                {
                    throw new ArgumentException("episode ids not set or have no valid id  - show title not valid", nameof(show.Title));
                }

                if (episode.SeasonNumber < 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(episode.SeasonNumber), "episode ids not set or have no valid id  - episode season number not valid");
                }

                if (episode.Number <= 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(episode.Number), "episode ids not set or have no valid id  - episode number not valid");
                }
            }
        }
Beispiel #8
0
        /// <summary>Adds a <see cref="TraktShow" />, which will be added to the history post.</summary>
        /// <param name="show">The Trakt show, which will be added.</param>
        /// <param name="watchedAt">The datetime, when the given show was watched. Will be converted to the Trakt UTC-datetime and -format.</param>
        /// <returns>The current <see cref="TraktSyncHistoryPostBuilder" /> instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown, if the given show is null.
        /// Thrown, if the given show ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown, if the given show has no valid ids set.
        /// Thrown, if the given show has an year set, which has more or less than four digits.
        /// </exception>
        public TraktSyncHistoryPostBuilder AddShow(TraktShow show, DateTime watchedAt)
        {
            ValidateShow(show);
            EnsureShowsListExists();

            return(AddShowOrIgnore(show, watchedAt));
        }
Beispiel #9
0
        /// <summary>Adds a <see cref="TraktShow" />, which will be added to the collection post.</summary>
        /// <param name="show">The Trakt show, which will be added.</param>
        /// <param name="metadata">An <see cref="TraktMetadata" /> instance, containing metadata about the given show.</param>
        /// <param name="collectedAt">The datetime, when the given show was collected. Will be converted to the Trakt UTC-datetime and -format.</param>
        /// <returns>The current <see cref="TraktSyncCollectionPostBuilder" /> instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown, if the given show is null.
        /// Thrown, if the given show ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown, if the given show has no valid ids set.
        /// Thrown, if the given show has an year set, which has more or less than four digits.
        /// </exception>
        public TraktSyncCollectionPostBuilder AddShow(TraktShow show, TraktMetadata metadata, DateTime collectedAt)
        {
            ValidateShow(show);
            EnsureShowsListExists();

            return(AddShowOrIgnore(show, metadata, collectedAt));
        }
Beispiel #10
0
        private TraktSyncCollectionPostBuilder AddShowOrIgnore(TraktShow show, TraktMetadata metadata = null,
                                                               DateTime?collectedAt = null)
        {
            if (ContainsShow(show))
            {
                return(this);
            }

            var collectionShow = new TraktSyncCollectionPostShow();

            collectionShow.Ids   = show.Ids;
            collectionShow.Title = show.Title;
            collectionShow.Year  = show.Year;

            if (metadata != null)
            {
                collectionShow.Metadata = metadata;
            }

            if (collectedAt.HasValue)
            {
                collectionShow.CollectedAt = collectedAt.Value.ToUniversalTime();
            }

            (_collectionPost.Shows as List <TraktSyncCollectionPostShow>).Add(collectionShow);

            return(this);
        }
        public void Test_TraktShow_Default_Constructor()
        {
            var show = new TraktShow();

            show.Title.Should().BeNullOrEmpty();
            show.Year.Should().NotHaveValue();
            show.Airs.Should().BeNull();
            show.AvailableTranslationLanguageCodes.Should().BeNull();
            show.Ids.Should().BeNull();
            show.Genres.Should().BeNull();
            show.Seasons.Should().BeNull();
            show.Overview.Should().BeNullOrEmpty();
            show.FirstAired.Should().NotHaveValue();
            show.Runtime.Should().NotHaveValue();
            show.Certification.Should().BeNullOrEmpty();
            show.Network.Should().BeNullOrEmpty();
            show.CountryCode.Should().BeNullOrEmpty();
            show.UpdatedAt.Should().NotHaveValue();
            show.Trailer.Should().BeNullOrEmpty();
            show.Homepage.Should().BeNullOrEmpty();
            show.Status.Should().BeNull();
            show.Rating.Should().NotHaveValue();
            show.Votes.Should().NotHaveValue();
            show.LanguageCode.Should().BeNullOrEmpty();
            show.AiredEpisodes.Should().NotHaveValue();
        }
Beispiel #12
0
        public TraktCommentsModule_Tests()
        {
            Movie = new TraktMovie
            {
                Title = "Guardians of the Galaxy",
                Year  = 2014,
                Ids   = new TraktMovieIds
                {
                    Trakt = 28,
                    Slug  = "guardians-of-the-galaxy-2014",
                    Imdb  = "tt2015381",
                    Tmdb  = 118340
                }
            };

            Show = new TraktShow
            {
                Title = "Breaking Bad",
                Ids   = new TraktShowIds
                {
                    Trakt  = 1388,
                    Slug   = "breaking bad",
                    Tvdb   = 81189,
                    Imdb   = "tt0903747",
                    Tmdb   = 1396,
                    TvRage = 18164
                }
            };

            Season = new TraktSeason
            {
                Ids = new TraktSeasonIds
                {
                    Trakt = 3950,
                    Tvdb  = 30272,
                    Tmdb  = 3572
                }
            };

            Episode = new TraktEpisode
            {
                Ids = new TraktEpisodeIds
                {
                    Trakt  = 73482,
                    Tvdb   = 349232,
                    Imdb   = "tt0959621",
                    Tmdb   = 62085,
                    TvRage = 637041
                }
            };

            List = new TraktList
            {
                Ids = new TraktListIds
                {
                    Trakt = 2228577,
                    Slug  = "oscars-2016"
                }
            };
        }
Beispiel #13
0
        public void UpdateEpisodeView(TraktEpisode episode, TraktShow show)
        {
            this.ShowName    = episode.Title;
            this.ShowYear    = show.year;
            this.Name        = episode.Title;
            this.Fanart      = show.Images.Fanart;
            this.Overview    = episode.Overview;
            this.Season      = episode.Season;
            this.Number      = episode.Number;
            this.Screen      = episode.Images.Screen;
            this.Imdb        = show.imdb_id;
            this.Tvdb        = show.tvdb_id;
            this._airDate    = episode.FirstAired;
            this.Watched     = episode.Watched;
            this.InWatchlist = episode.InWatchlist;
            this.Year        = show.year;

            if (episode.Ratings != null)
            {
                this.Rating           = episode.Ratings.Percentage;
                this.Votes            = episode.Ratings.Votes;
                this.MyRating         = episode.MyRating;
                this.MyRatingAdvanced = episode.MyRatingAdvanced;
                NotifyPropertyChanged("RatingString");
                NotifyPropertyChanged("RatingImage");
                NotifyPropertyChanged("AllRatingImage");
                NotifyPropertyChanged("VotesString");
            }

            NotifyPropertyChanged("LoadingStatusEpisode");
            NotifyPropertyChanged("DetailVisibility");
        }
        private TraktSyncRatingsPostBuilder AddShowOrIgnore(TraktShow show, int?rating = null, DateTime?ratedAt = null)
        {
            if (ContainsShow(show))
            {
                return(this);
            }

            var ratingsShow = new TraktSyncRatingsPostShow();

            ratingsShow.Ids   = show.Ids;
            ratingsShow.Title = show.Title;
            ratingsShow.Year  = show.Year;

            if (rating.HasValue)
            {
                ratingsShow.Rating = rating;
            }

            if (ratedAt.HasValue)
            {
                ratingsShow.RatedAt = ratedAt.Value.ToUniversalTime();
            }

            (_ratingsPost.Shows as List <TraktSyncRatingsPostShow>).Add(ratingsShow);

            return(this);
        }
Beispiel #15
0
        private void DismissRecommendation(TraktShow show)
        {
            Thread syncThread = new Thread(delegate(object obj)
            {
                TraktShow dismissShow = obj as TraktShow;

                TraktShowSlug syncShow = new TraktShowSlug
                {
                    UserName = TraktSettings.Username,
                    Password = TraktSettings.Password,
                    IMDbId   = dismissShow.Imdb,
                    TVDbId   = dismissShow.Tvdb,
                    Title    = dismissShow.Title,
                    Year     = dismissShow.Year.ToString()
                };

                TraktResponse response = TraktAPI.TraktAPI.DismissShowRecommendation(syncShow);
                TraktLogger.LogTraktResponse <TraktResponse>(response);
            })
            {
                IsBackground = true,
                Name         = "DismissRecommendation"
            };

            syncThread.Start(show);
        }
Beispiel #16
0
        private async void CheckinEpisode_Click(object sender, RoutedEventArgs e)
        {
            this.indicator = App.ShowLoading(this);
            lastModel      = (ListItemViewModel)((MenuItem)sender).DataContext;

            if (await episodeController.checkinEpisode(lastModel.Tvdb, lastModel.Name, lastModel.Year, lastModel.Season, lastModel.Episode))
            {
                if (lastModel != null)
                {
                    lastModel.Watched = true;
                }
                TraktShow show = await showController.getShowByTVDBID(lastModel.Tvdb);

                ShowWatchingNowShow(await episodeController.getEpisodeByTvdbAndSeasonInfo(lastModel.Tvdb, lastModel.Season, lastModel.Episode, show), show, DateTime.UtcNow);

                ToastNotification.ShowToast("Show", "Checked in!");
            }
            else
            {
                ErrorManager.ShowConnectionErrorPopup();
            }

            lastModel = null;
            this.indicator.IsVisible = false;
        }
Beispiel #17
0
        private void OnShowSelected(GUIListItem item, GUIControl parent)
        {
            TraktShow show = item.TVTag as TraktShow;

            PublishShowSkinProperties(show);
            GUIImageHandler.LoadFanart(backdrop, show.Images.FanartImageFilename);
        }
Beispiel #18
0
        private TraktShowSync CreateSyncData(TraktShow show)
        {
            if (show == null)
            {
                return(null);
            }

            List <TraktShowSync.Show> shows = new List <TraktShowSync.Show>();

            TraktShowSync.Show syncShow = new TraktShowSync.Show
            {
                TVDBID = show.Tvdb,
                Title  = show.Title,
                Year   = show.Year
            };
            shows.Add(syncShow);

            TraktShowSync syncData = new TraktShowSync
            {
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password,
                Shows    = shows
            };

            return(syncData);
        }
        private void CreateOrSetShow(TraktShow show, IEnumerable <TraktSyncRatingsPostShowSeason> showSeasons,
                                     int?rating = null, DateTime?ratedAt = null)
        {
            var existingShow = _ratingsPost.Shows.Where(s => s.Ids == show.Ids).FirstOrDefault();

            if (existingShow != null)
            {
                existingShow.Seasons = showSeasons;
            }
            else
            {
                var ratingsShow = new TraktSyncRatingsPostShow();
                ratingsShow.Ids   = show.Ids;
                ratingsShow.Title = show.Title;
                ratingsShow.Year  = show.Year;

                if (rating.HasValue)
                {
                    ratingsShow.Rating = rating;
                }

                if (ratedAt.HasValue)
                {
                    ratingsShow.RatedAt = ratedAt.Value.ToUniversalTime();
                }

                ratingsShow.Seasons = showSeasons;
                (_ratingsPost.Shows as List <TraktSyncRatingsPostShow>).Add(ratingsShow);
            }
        }
Beispiel #20
0
        protected void CreateOrSetShow(TraktShow show, IEnumerable <TraktSyncHistoryPostShowSeason> showSeasons,
                                       DateTime?watchedAt = null)
        {
            var existingShow = _historyPost.Shows.Where(s => s.Ids == show.Ids).FirstOrDefault();

            if (existingShow != null)
            {
                existingShow.Seasons = showSeasons;
            }
            else
            {
                var historyShow = new TraktSyncHistoryPostShow();
                historyShow.Ids   = show.Ids;
                historyShow.Title = show.Title;
                historyShow.Year  = show.Year;

                if (watchedAt.HasValue)
                {
                    historyShow.WatchedAt = watchedAt.Value.ToUniversalTime();
                }

                historyShow.Seasons = showSeasons;
                (_historyPost.Shows as List <TraktSyncHistoryPostShow>).Add(historyShow);
            }
        }
Beispiel #21
0
        private async void LoadShow(String tvdb)
        {
            this.progressBarLoading.Visibility = System.Windows.Visibility.Visible;

            this.Show = await showController.getShowByTVDBID(tvdb);

            if (this.Show != null)
            {
                App.ShowViewModel.LoadData(tvdb);

                if (!String.IsNullOrEmpty(this.Show.GenresAsString))
                {
                    this.Show.Genres = this.Show.GenresAsString.Split('|');
                }

                App.ShowViewModel.UpdateShowView(this.Show);

                if (this.Show.Seasons.Count == 0)
                {
                    LoadSeasons(tvdb);
                }
                else
                {
                    App.ShowViewModel.NumberOfSeasons = (Int16)this.Show.Seasons.Count;
                }

                LoadBackgroundImage();
            }
            else
            {
                ErrorManager.ShowConnectionErrorPopup();
            }

            this.progressBarLoading.Visibility = System.Windows.Visibility.Collapsed;
        }
Beispiel #22
0
        /// <summary>Adds a <see cref="TraktShow" />, which will be added to the collection post.</summary>
        /// <param name="show">The Trakt show, which will be added.</param>
        /// <returns>The current <see cref="TraktSyncCollectionPostBuilder" /> instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown, if the given show is null.
        /// Thrown, if the given show ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown, if the given show has no valid ids set.
        /// Thrown, if the given show has an year set, which has more or less than four digits.
        /// </exception>
        public TraktSyncCollectionPostBuilder AddShow(TraktShow show)
        {
            ValidateShow(show);
            EnsureShowsListExists();

            return(AddShowOrIgnore(show));
        }
        /// <summary>Adds a <see cref="TraktShow" />, which will be added to the ratings post.</summary>
        /// <param name="show">The Trakt show, which will be added.</param>
        /// <param name="rating">A rating from 1 to 10 for the given show.</param>
        /// <param name="ratedAt">The datetime, when the given show was rated. Will be converted to the Trakt UTC-datetime and -format.</param>
        /// <returns>The current <see cref="TraktSyncRatingsPostBuilder" /> instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown, if the given show is null.
        /// Thrown, if the given show ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown, if the given show has no valid ids set.
        /// Thrown, if the given show has an year set, which has more or less than four digits.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown, if the given rating is not between 1 and 10.</exception>
        public TraktSyncRatingsPostBuilder AddShowWithRating(TraktShow show, int rating, DateTime ratedAt)
        {
            ValidateShow(show);
            ValidateRating(rating);
            EnsureShowsListExists();

            return(AddShowOrIgnore(show, rating, ratedAt));
        }
Beispiel #24
0
        static async Task GetShowMinimal(string showIdOrSlug)
        {
            Console.WriteLine("------------------------- Show Minimal -------------------------");
            TraktShow show = await _client.Shows.GetShowAsync(showIdOrSlug);

            WriteShowMinimal(show);
            Console.WriteLine("----------------------------------------------------------------");
        }
Beispiel #25
0
        private void ShowSelected(TraktShow show)
        {
            var navParam = new NavigationParameters {
                { nameof(show), show }
            };

            NavigationService.NavigateAsync(nameof(MyShowDetailPage), navParam);
        }
Beispiel #26
0
 public static bool IsMatch(BaseItem item, TraktShow show)
 {
     return
         (MatchIds(item.GetProviderId(MetadataProviders.Tvdb), show.ids.tvdb) ||
          MatchIds(item.GetProviderId(MetadataProviders.Imdb), show.ids.imdb) ||
          MatchIds(item.GetProviderId(MetadataProviders.Tmdb), show.ids.tmdb) ||
          MatchIds(item.GetProviderId(MetadataProviders.TvRage), show.ids.tvrage));
 }
Beispiel #27
0
        private void OnShowSelected(GUIListItem item, GUIControl parent)
        {
            PreviousSelectedIndex = Facade.SelectedListItemIndex;

            TraktShow show = item.TVTag as TraktShow;

            PublishShowSkinProperties(show);
            GUIImageHandler.LoadFanart(backdrop, show.Images.Fanart.LocalImageFilename(ArtworkType.ShowFanart));
        }
Beispiel #28
0
        public void loadRecent()
        {
            if (!Loading)
            {
                this.EmptyRecent.Visibility = System.Windows.Visibility.Collapsed;
                this.indicator = App.ShowLoading(this);
                this.Loading   = true;
                App.ViewModel.clearRecent();
                TraktShow[]  shows  = showController.getRecentShows();
                TraktMovie[] movies = movieController.getRecentMovies();

                List <Object> mergedList = new List <object>();
                mergedList.AddRange(shows);
                mergedList.AddRange(movies);

                mergedList.Sort((x, y) => DateTime.Compare(DateTime.Parse(y.ToString()), (DateTime.Parse(x.ToString()))));

                foreach (Object movieOrShow in mergedList)
                {
                    if (App.ViewModel.RecentItems.Count == 12)
                    {
                        break;
                    }

                    if (typeof(TraktShow) == movieOrShow.GetType())
                    {
                        TraktShow         show     = (TraktShow)movieOrShow;
                        ListItemViewModel newModel = new ListItemViewModel()
                        {
                            ImageSource = show.Images.Poster, Tvdb = show.tvdb_id, Type = "show"
                        };
                        App.ViewModel.RecentItems.Add(newModel);
                        newModel.LoadPosterImage();
                    }
                    else
                    {
                        TraktMovie        movie    = (TraktMovie)movieOrShow;
                        ListItemViewModel newModel = new ListItemViewModel()
                        {
                            ImageSource = movie.Images.Poster, Imdb = movie.imdb_id, Type = "movie"
                        };
                        App.ViewModel.RecentItems.Add(newModel);
                        newModel.LoadPosterImage();
                    }
                }

                if (App.ViewModel.RecentItems.Count == 0)
                {
                    this.EmptyRecent.Visibility = System.Windows.Visibility.Visible;
                }

                App.ViewModel.NotifyPropertyChanged("RecentItems");

                this.indicator.IsVisible = false;
                this.Loading             = false;
            }
        }
Beispiel #29
0
        public void deleteSeason(TraktShow traktShow, short season)
        {
            if (traktShow != null)
            {
                TraktSeason traktseason = showDao.getSeasonFromShow(traktShow, season);

                showDao.deleteSeasonEpisodes(traktseason);
            }
        }
Beispiel #30
0
        public void Test_TraktPost_UserCustomListItemsPostBuilder_AddShowAndSeasonsCollection()
        {
            ITraktShow show = new TraktShow
            {
                Ids = new TraktShowIds
                {
                    Trakt  = 1,
                    Slug   = "show-title",
                    Imdb   = "ttshowtitle",
                    Tmdb   = 1,
                    Tvdb   = 1,
                    TvRage = 1
                }
            };

            var seasons = new PostSeasons
            {
                1,
                { 2, new PostEpisodes {
                      1, 2
                  } }
            };

            ITraktUserCustomListItemsPost userCustomListItemsPost = TraktPost.NewUserCustomListItemsPost()
                                                                    .AddShowAndSeasonsCollection(show).WithSeasons(seasons)
                                                                    .Build();

            userCustomListItemsPost.Should().NotBeNull();
            userCustomListItemsPost.Shows.Should().NotBeNull().And.HaveCount(1);

            ITraktUserCustomListItemsPostShow postShow = userCustomListItemsPost.Shows.ToArray()[0];

            postShow.Ids.Should().NotBeNull();
            postShow.Ids.Trakt.Should().Be(1U);
            postShow.Ids.Slug.Should().Be("show-title");
            postShow.Ids.Imdb.Should().Be("ttshowtitle");
            postShow.Ids.Tmdb.Should().Be(1U);
            postShow.Ids.Tvdb.Should().Be(1U);
            postShow.Ids.TvRage.Should().Be(1U);
            postShow.Seasons.Should().NotBeNull().And.HaveCount(2);

            ITraktUserCustomListItemsPostShowSeason[] showSeasons = postShow.Seasons.ToArray();

            showSeasons[0].Number.Should().Be(1);
            showSeasons[0].Episodes.Should().BeNull();

            showSeasons[1].Number.Should().Be(2);
            showSeasons[1].Episodes.Should().NotBeNull().And.HaveCount(2);

            ITraktUserCustomListItemsPostShowEpisode[] showSeasonPeople = showSeasons[1].Episodes.ToArray();

            showSeasonPeople[0].Number.Should().Be(1);
            showSeasonPeople[1].Number.Should().Be(2);

            userCustomListItemsPost.Movies.Should().NotBeNull().And.BeEmpty();
            userCustomListItemsPost.People.Should().NotBeNull().And.BeEmpty();
        }