예제 #1
0
        /// <summary>
        /// Available options are: popularity.ascpopularity.descrelease_date.ascrelease_date.descrevenue.ascrevenue.descprimary_release_date.ascprimary_release_date.descoriginal_title.ascoriginal_title.descvote_average.ascvote_average.descvote_count.ascvote_count.desc
        /// </summary>
        public DiscoverMovie OrderBy(string sortBy)
        {
            DiscoverMovieSortBy movieSortBy = DiscoverMovieSortBy.PopularityDesc;

            Enum.TryParse(sortBy, true, out movieSortBy);

            return(OrderBy(movieSortBy));
        }
예제 #2
0
        //FilterMovie Controller
        public async Task <IActionResult> FilterMovie(int[] genres, int?page, DiscoverMovieSortBy sortby, int year)
        {
            TMDbClient client = new TMDbClient("02214396be00b0615b4005941508943d");

            var pageNumber = page ?? 1;

            await FetchConfig(client);

            return(View(FilterMovies(client, genres, pageNumber, sortby, year)));
        }
예제 #3
0
        public SearchContainer <SearchMovie> Discover(DateTime startDate, DateTime endDate, string language = "en",
                                                      DiscoverMovieSortBy movieSortBy =
                                                      DiscoverMovieSortBy.ReleaseDateDescending,
                                                      int voteAverageGreaterThan = 5,
                                                      int page = 0)
        {
            SearchContainer <SearchMovie> movies = _client.DiscoverMovies(language: language
                                                                          , voteAverageGreaterThan: voteAverageGreaterThan
                                                                          , releaseDateGreaterThan: startDate
                                                                          , releaseDateLessThan: endDate
                                                                          , sortBy: DiscoverMovieSortBy.ReleaseDateDescending
                                                                          , page: page);

            return(movies);
        }
예제 #4
0
        //Discover Movie through filtering
        private static PagedResult <Movie> FilterMovies(TMDbClient client, int[] genre, int page, DiscoverMovieSortBy sortby, int year)
        {
            DiscoverMovie query = client.DiscoverMoviesAsync().IncludeWithAllOfGenre(genre).WherePrimaryReleaseIsInYear(year).OrderBy(sortby);

            SearchContainer <SearchMovie> results = query.Query(page).Result;

            var getMovies = (from result in results.Results
                             select new
            {
                Title = result.Title,
                PosterPath = result.PosterPath,
                Id = result.Id
            }).ToList().Select(p => new Movie()
            {
                Title      = p.Title,
                PosterPath = p.PosterPath,
                Id         = p.Id
            });
            var pagedMovie = new PagedResult <Movie>
            {
                Data       = getMovies.ToList(),
                TotalItems = results.TotalResults,
                PageNumber = page,
                PageSize   = 21
            };

            return(pagedMovie);
        }
예제 #5
0
 /// <summary>
 /// Available options are: popularity.ascpopularity.descrelease_date.ascrelease_date.descrevenue.ascrevenue.descprimary_release_date.ascprimary_release_date.descoriginal_title.ascoriginal_title.descvote_average.ascvote_average.descvote_count.ascvote_count.desc
 /// </summary>
 public DiscoverMovie OrderBy(DiscoverMovieSortBy sortBy)
 {
     Parameters["sort_by"] = sortBy.GetDescription();
     return(this);
 }
예제 #6
0
        public async Task DiscoverMovieSmokeTest(string language, string region,
                                                 DiscoverMovieSortBy sortBy, string certificationCountry, string certification,
                                                 string certificationLessThanOrEqualTo, string certificationGreaterThanOrEqualTo,
                                                 bool?includeAdult, bool?includeVideo, int page, int?primaryReleaseYear,
                                                 string primaryReleaseDateGreaterThanOrEqualTo, string primaryReleaseDateLessThanOrEqualTo,
                                                 string releaseDateGreaterThanOrEqualTo, string releaseDateLessThanOrEqualTo,
                                                 IEnumerable <MovieReleaseType> withReleaseTypes, Delimeter withReleaseTypesDelimeter,
                                                 int?year, int?voteCountGreaterThanOrEqualTo, int?voteCountLessThanOrEqualTo,
                                                 int?voteAverageGreaterThanOrEqualTo, int?voteAverageLessThanOrEqualTo,
                                                 IEnumerable <int> withCastIds, IEnumerable <int> withCrewIds, IEnumerable <int> withPeopleIds,
                                                 IEnumerable <int> withCompanyIds, IEnumerable <int> withGenreIds, Delimeter withGenreIdsDelimeter,
                                                 IEnumerable <int> withoutGenreIds, Delimeter withoutGenreIdsDelimeter, IEnumerable <int> withKeywordIds,
                                                 Delimeter withKeywordIdsDelimeter, IEnumerable <int> withoutKeywordIds, Delimeter withoutKeywordIdsDelimeter,
                                                 int?withRuntimeGreaterThanOrEqualTo, int?withRuntimeLessThanOrEqualTo, string withOriginalLanguageAbbreviation,
                                                 IEnumerable <int> withWatchProviderIds, Delimeter withWatchProviderIdsDelimeter, string withWatchProviderRegionCountryCode)
        {
            var response = await Client.Discover.GetAsync(new DiscoverMovieRequest
            {
                LanguageAbbreviation = language,
                RegionCountryCode    = region,
                SortBy = sortBy,
                CertificationCountry              = certificationCountry,
                Certification                     = certification,
                CertificationLessThanOrEqualTo    = certificationLessThanOrEqualTo,
                CertificationGreaterThanOrEqualTo = certificationGreaterThanOrEqualTo,
                IncludeAdult       = includeAdult,
                IncludeVideo       = includeVideo,
                Page               = page,
                PrimaryReleaseYear = primaryReleaseYear.HasValue ? Convert.ToInt16(primaryReleaseYear) : null,
                PrimaryReleaseDateGreaterThanOrEqualTo = !string.IsNullOrEmpty(primaryReleaseDateGreaterThanOrEqualTo) ? DateTime.Parse(primaryReleaseDateGreaterThanOrEqualTo) : null,
                PrimaryReleaseDateLessThanOrEqualTo    = !string.IsNullOrEmpty(primaryReleaseDateLessThanOrEqualTo) ? DateTime.Parse(primaryReleaseDateLessThanOrEqualTo) : null,
                ReleaseDateGreaterThanOrEqualTo        = !string.IsNullOrEmpty(releaseDateGreaterThanOrEqualTo) ? DateTime.Parse(releaseDateGreaterThanOrEqualTo) : null,
                ReleaseDateLessThanOrEqualTo           = !string.IsNullOrEmpty(releaseDateLessThanOrEqualTo) ? DateTime.Parse(releaseDateLessThanOrEqualTo) : null,
                WithReleaseTypes          = withReleaseTypes,
                WithReleaseTypesDelimeter = withReleaseTypesDelimeter,
                Year = year.HasValue ? Convert.ToInt16(year) : null,
                VoteCountGreaterThanOrEqualTo   = voteCountGreaterThanOrEqualTo,
                VoteCountLessThanOrEqualTo      = voteCountLessThanOrEqualTo,
                VoteAverageGreaterThanOrEqualTo = voteAverageGreaterThanOrEqualTo,
                VoteAverageLessThanOrEqualTo    = voteAverageLessThanOrEqualTo,
                WithCastIds                        = withCastIds,
                WithCrewIds                        = withCrewIds,
                WithPeopleIds                      = withPeopleIds,
                WithCompanyIds                     = withCompanyIds,
                WithGenreIds                       = withGenreIds,
                WithGenreIdsDelimeter              = withGenreIdsDelimeter,
                WithoutGenreIds                    = withoutGenreIds,
                WithoutGenreIdsDelimeter           = withoutGenreIdsDelimeter,
                WithKeywordIds                     = withKeywordIds,
                WithKeywordIdsDelimeter            = withKeywordIdsDelimeter,
                WithoutKeywordIds                  = withoutKeywordIds,
                WithoutKeywordIdsDelimeter         = withoutKeywordIdsDelimeter,
                WithRuntimeGreaterThanOrEqualTo    = withRuntimeGreaterThanOrEqualTo,
                WithRuntimeLessThanOrEqualTo       = withRuntimeLessThanOrEqualTo,
                WithOriginalLanguageAbbreviation   = withOriginalLanguageAbbreviation,
                WithWatchProviderIds               = withWatchProviderIds,
                WithWatchProviderIdsDelimeter      = withWatchProviderIdsDelimeter,
                WithWatchProviderRegionCountryCode = withWatchProviderRegionCountryCode,
            });

            Assert.IsType <DiscoverMovieResponse>(response);
            Assert.True(response.Results.Any());
        }