// ------------------------------------------------------------- // Popular Movies public async Task <PaginationList <Movie> > GetPopularMoviesAsync(TraktExtendedInfo extendedInfo = null, TraktMovieFilter movieFilter = null, int?whichPage = null, int?limitPerPage = null) { var traktResults = await Client.Movies.GetPopularMoviesAsync(extendedInfo, movieFilter, whichPage, limitPerPage); var results = new PaginationList <Movie> { CurrentPage = traktResults.Page, TotalPages = traktResults.PageCount, LimitPerPage = traktResults.Limit, TotalItemCount = traktResults.ItemCount, TotalUserCount = traktResults.UserCount }; results.Items = new ObservableCollection <Movie>(); foreach (var traktPopularMovie in traktResults) { var popularMovie = MovieModelConverter.Convert <Movie>(traktPopularMovie); if (popularMovie != null) { results.Items.Add(popularMovie); } } return(results); }
// ------------------------------------------------------------- // Recently Updated Movies public async Task <PaginationList <RecentlyUpdatedMovie> > GetRecentlyUpdatedMoviesAsync(DateTime?startDate = null, TraktExtendedInfo extendedInfo = null, int?whichPage = null, int?limitPerPage = null) { var traktResults = await Client.Movies.GetRecentlyUpdatedMoviesAsync(startDate, extendedInfo, whichPage, limitPerPage); var results = new PaginationList <RecentlyUpdatedMovie> { CurrentPage = traktResults.Page, TotalPages = traktResults.PageCount, LimitPerPage = traktResults.Limit, TotalItemCount = traktResults.ItemCount, TotalUserCount = traktResults.UserCount }; results.Items = new ObservableCollection <RecentlyUpdatedMovie>(); foreach (var traktRecentlyUpdatedMovie in traktResults) { var recentlyUpdatedMovie = MovieModelConverter.Convert <RecentlyUpdatedMovie>(traktRecentlyUpdatedMovie.Movie); if (recentlyUpdatedMovie != null) { var updatedAt = traktRecentlyUpdatedMovie.UpdatedAt; recentlyUpdatedMovie.MovieUpdatedAt = updatedAt.HasValue ? updatedAt.ToString() : string.Empty; results.Items.Add(recentlyUpdatedMovie); } } return(results); }
// ------------------------------------------------------------- // Most Collected Movies public async Task <PaginationList <MostPWCMovie> > GetMostCollectedMoviesAsync(TraktExtendedInfo extendedInfo = null, TraktMovieFilter movieFilter = null, TraktTimePeriod period = null, int?whichPage = null, int?limitPerPage = null) { var traktResults = await Client.Movies.GetMostCollectedMoviesAsync(period, extendedInfo, movieFilter, whichPage, limitPerPage); var results = new PaginationList <MostPWCMovie> { CurrentPage = traktResults.Page, TotalPages = traktResults.PageCount, LimitPerPage = traktResults.Limit, TotalItemCount = traktResults.ItemCount, TotalUserCount = traktResults.UserCount }; results.Items = new ObservableCollection <MostPWCMovie>(); foreach (var traktMostCollectedMovie in traktResults) { var mostCollectedMovie = MovieModelConverter.Convert <MostPWCMovie>(traktMostCollectedMovie.Movie); if (mostCollectedMovie != null) { mostCollectedMovie.WatcherCount = traktMostCollectedMovie.WatcherCount.GetValueOrDefault(); mostCollectedMovie.PlayCount = traktMostCollectedMovie.PlayCount.GetValueOrDefault(); mostCollectedMovie.CollectedCount = traktMostCollectedMovie.CollectedCount.GetValueOrDefault(); results.Items.Add(mostCollectedMovie); } } return(results); }
// ------------------------------------------------------------- // Box Office Movies public async Task <ObservableCollection <BoxOfficeMovie> > GetBoxOfficeMoviesAsync(TraktExtendedInfo extendedInfo = null) { var traktResults = await Client.Movies.GetBoxOfficeMoviesAsync(extendedInfo); var results = new ObservableCollection <BoxOfficeMovie>(); foreach (var traktBoxOfficeMovie in traktResults) { var boxOfficeMovie = MovieModelConverter.Convert <BoxOfficeMovie>(traktBoxOfficeMovie.Movie); if (boxOfficeMovie != null) { boxOfficeMovie.Revenue = traktBoxOfficeMovie.Revenue.GetValueOrDefault(); results.Add(boxOfficeMovie); } } return(results); }