Ejemplo n.º 1
0
        private IEnumerable <ITraktSyncRatingsPostShowSeason> CreateSyncRatingsPostShowSeasons(PostRatingsSeasons seasons)
        {
            var syncRatingsPostShowSeasons = new List <ITraktSyncRatingsPostShowSeason>();

            foreach (PostRatingsSeason season in seasons)
            {
                var syncRatingsPostShowSeason = new TraktSyncRatingsPostShowSeason
                {
                    Number = season.Number
                };

                if (season.Rating.HasValue)
                {
                    syncRatingsPostShowSeason.Rating = season.Rating.Value;
                }

                if (season.RatedAt.HasValue)
                {
                    syncRatingsPostShowSeason.RatedAt = season.RatedAt.Value.ToUniversalTime();
                }

                if (season.Episodes?.Count() > 0)
                {
                    var syncRatingsPostShowEpisodes = new List <ITraktSyncRatingsPostShowEpisode>();

                    foreach (PostRatingsEpisode episode in season.Episodes)
                    {
                        var syncRatingsPostShowEpisode = new TraktSyncRatingsPostShowEpisode
                        {
                            Number = episode.Number
                        };

                        if (episode.Rating.HasValue)
                        {
                            syncRatingsPostShowEpisode.Rating = episode.Rating.Value;
                        }

                        if (episode.RatedAt.HasValue)
                        {
                            syncRatingsPostShowEpisode.RatedAt = episode.RatedAt.Value.ToUniversalTime();
                        }

                        syncRatingsPostShowEpisodes.Add(syncRatingsPostShowEpisode);
                    }

                    syncRatingsPostShowSeason.Episodes = syncRatingsPostShowEpisodes;
                }

                syncRatingsPostShowSeasons.Add(syncRatingsPostShowSeason);
            }

            return(syncRatingsPostShowSeasons);
        }
Ejemplo n.º 2
0
        private ITraktSyncRatingsPostShow CreateSyncRatingsPostShowWithSeasonsCollection(ITraktShow show, int?rating = null, DateTime?ratedAt = null, PostRatingsSeasons seasons = null)
        {
            var syncRatingsPostShow = CreateSyncRatingsPostShow(show, rating, ratedAt);

            if (seasons != null)
            {
                syncRatingsPostShow.Seasons = CreateSyncRatingsPostShowSeasons(seasons);
            }

            return(syncRatingsPostShow);
        }