Esempio n. 1
0
        private void CreateOrSetShow(ITraktShow show, IEnumerable <ITraktSyncRatingsPostShowSeason> showSeasons,
                                     int?rating = null, DateTime?ratedAt = null)
        {
            var existingShow = _ratingsPost.Shows.FirstOrDefault(s => s.Ids == show.Ids);

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

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

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

                ratingsShow.Seasons = showSeasons;
                (_ratingsPost.Shows as List <ITraktSyncRatingsPostShow>)?.Add(ratingsShow);
            }
        }
Esempio n. 2
0
        private TraktSyncRatingsPostBuilder AddShowOrIgnore(ITraktShow show, int?rating = null, DateTime?ratedAt = null)
        {
            if (ContainsShow(show))
            {
                return(this);
            }

            var ratingsShow = new TraktSyncRatingsPostShow
            {
                Ids   = show.Ids,
                Title = show.Title,
                Year  = show.Year
            };

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

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

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

            return(this);
        }