public async Task <GetMultipleResponse <TVShow> > DiscoverTVShowsAsync(DiscoverTVShowsRequest request) { return(await ExecuteAsync <GetMultipleResponse <TVShow> >(request, async response => { var uriQuery = $"api_key={_v3Key}&page={request.page}&with_genres={string.Join(',', request.genres.ToArray())}&language={request.language}®ion={request.region}"; var getResponse = await _httpClient.GetAsync($"{_baseAddress}/discover/tv?{uriQuery}"); if (getResponse.IsSuccessStatusCode) { var tmdbResponse = JsonConvert.DeserializeObject <TMDbResponse <TVShow> >(await getResponse.Content.ReadAsStringAsync()); response.Page = tmdbResponse.page; response.Results = tmdbResponse.results; response.TotalPages = tmdbResponse.total_pages; //response.TotalResults = tmdbResponse.total_results; } else { throw new ApiException(await getResponse.Content.ReadAsStringAsync(), statusCode: (int)getResponse.StatusCode); } })); }
public async Task <IActionResult> DiscoverTVShows([FromQuery] DiscoverTVShowsRequest request) { return(Ok(await _client.DiscoverTVShowsAsync(request))); }