private async Task LoadInfoAsync() { var tmdbConfig = await TheMovieDb.GetConfiguration(); var tmdbInfo = await TheMovieDb.SearchPersonAsync(_name); if (tmdbInfo.Results != null && tmdbInfo.Results.Count == 1) { var details = await tmdbInfo.Results[0].PersonAsync(); Info = new TmdbPerson(tmdbConfig, details); } }
async protected override Task <DataListPageResult <TmdbItem> > FetchPageAsync(int pageNumber) { if (_config == null) { _config = await TheMovieDb.GetConfiguration(); } if (personID == null) { personID = 0; var resultPerson = await TheMovieDb.SearchPersonAsync(_query, 1); if (resultPerson.Results != null && resultPerson.Results.Count == 1) { personID = resultPerson.Results[0].Id; } } if (personID == 0) { return(new DataListPageResult <TmdbItem>(0, PageSize, pageNumber, new List <TmdbItem>())); } if (_credits == null) { _credits = await TheMovieDb.GetCreditsAsync(personID.Value); } List <TmdbItem> list = new List <TmdbItem>(); var movies = _credits.Cast.Skip((pageNumber - 1) * PageSize).Take((pageNumber - 1) * PageSize + PageSize).Select(r => r.Id); foreach (var movieId in movies) { var movie = await TheMovieDb.GetMovieAsync(movieId); var tmdbItem = new TmdbItem (_config, movie); list.Add(tmdbItem); } return(new DataListPageResult <TmdbItem>(_credits.Cast.Count, PageSize, pageNumber, list)); }
async protected override Task <DataListPageResult <TmdbPerson> > FetchPageAsync(int pageNumber) { if (_config == null) { _config = await TheMovieDb.GetConfiguration(); } var result = await TheMovieDb.SearchPersonAsync(_query, pageNumber); List <TmdbPerson> list; if (result.Results != null) { list = result.Results.Select(PersonFactory).ToList(); } else { list = new List <TmdbPerson>(); } return(new DataListPageResult <TmdbPerson>(result.TotalResults, PageSize, pageNumber, list)); }