Exemplo n.º 1
0
        private void GetSearchResults()
        {
            Task.Run(async() =>
            {
                if (!string.IsNullOrWhiteSpace(SearchState.Query))
                {
                    MediaResults data;

                    switch (SearchState.Filter)
                    {
                    case SearchFilterType.All:
                        data = await SearchService.GetMultiSearchAsync(SearchState.Query, SearchState.Page);
                        break;

                    case SearchFilterType.Movies:
                        data = await SearchService.GetMovieSearchAsync(SearchState.Query, SearchState.Page);
                        break;

                    case SearchFilterType.TV:
                        data = await SearchService.GetTVSearchAsync(SearchState.Query, SearchState.Page);
                        break;

                    case SearchFilterType.People:
                        data = await SearchService.GetPeopleSearchAsync(SearchState.Query, SearchState.Page);
                        break;

                    default:
                        data = await SearchService.GetMultiSearchAsync(SearchState.Query, SearchState.Page);
                        break;
                    }

                    if (data is not null)
                    {
                        SearchState.SetResults(data.Results);
                        SearchState.SetTotalPages(data.Total_Pages);
                        SearchState.SetTotalResults(data.Total_Results);
                    }

                    NavigateToSearch();
                }
            }).Wait(new TimeSpan(4000000));
        }