예제 #1
0
        /// <summary>
        /// Searches asynchronously Api for the query. Returns <see cref="MediaSearchResult"/> that contains ID required to get a detail model of the media.
        /// </summary>
        /// <param name="query">Search query</param>
        /// <returns><see cref="MediaSearchResult"/> that contains ID required to get a detail model of the media.</returns>
        public async Task <List <MediaSearchResult> > SearchMultiByQueryAsync(string query)
        {
            List <MediaSearchResult> mediaList = new List <MediaSearchResult>();

            MovieDatabaseApiRequest request = new MovieDatabaseApiRequest(_apiKey, ApiRequestType.SearchMulti);

            request.AddQueryParameter("query", query);
            request.AddQueryParameter("language", Settings.CultureInfo.TwoLetterISOLanguageName);

            string responseString = await request.GetResponseAsync();

            SearchResponse response = JsonConvert.DeserializeObject <SearchResponse>(responseString, _jsonSettings);

            foreach (SearchResult result in response.Results)
            {
                if (result.MediaType != MediaType.Person)
                {
                    mediaList.Add(result);
                }
            }

            return(mediaList);
        }