Exemple #1
0
        private void SearchByText(string text)
        {
            songPage   = null;
            albumPage  = null;
            artistPage = null;

            int amount = searchFocus == SearchFocus.Any ? 3 : 10;

            if (SearchFocus == SearchFocus.Any)
            {
                RestClient.ExecuteAsync <CommonSearchResult>(RequestFactory.CommonSearchRequest(text, Page, amount), (r, c) =>
                {
                    if (r.Succeeded())
                    {
                        var data   = r.Data;
                        songPage   = data.songResult;
                        albumPage  = data.albumResult;
                        artistPage = data.artistResult;
                        ShowSearchResults();
                    }
                    else
                    {
                        ApplicationViewModel.HandlExceptionResponse(r.ExceptionResponse());
                    }
                });
            }

            if (SearchFocus == SearchFocus.Songs)
            {
                RestClient.ExecuteAsync <Page <Song> >(RequestFactory.SearchSongsRequest(text, Page, amount), (r, c) =>
                {
                    if (r.Succeeded())
                    {
                        songPage = r.Data;
                        ShowSearchResults();
                    }
                    else
                    {
                        ApplicationViewModel.HandlExceptionResponse(r.ExceptionResponse());
                    }
                });

                /*Response<Page<Song>> response = DataProvider.SearchSongsByTitle(text, Page, amount);
                 * if (!response.Status)
                 * {
                 *  ApplicationViewModel.HandleError(response.Error);
                 *  return;
                 * }
                 * songPage = response.Content;*/
            }
            if (SearchFocus == SearchFocus.Albums)
            {
                RestClient.ExecuteAsync <Page <Album> >(RequestFactory.SearchAlbumsRequest(text, Page, amount), (r, c) =>
                {
                    if (r.Succeeded())
                    {
                        albumPage = r.Data;
                        ShowSearchResults();
                    }
                    else
                    {
                        ApplicationViewModel.HandlExceptionResponse(r.ExceptionResponse());
                    }
                });

                /*Response<Page<Album>> response = DataProvider.SearchAlbumsByName(text, Page, amount);
                 * if (!response.Status)
                 * {
                 *  ApplicationViewModel.HandleError(response.Error);
                 *  return;
                 * }
                 * albumPage = response.Content;*/
            }
            if (SearchFocus == SearchFocus.Artists)
            {
                RestClient.ExecuteAsync <Page <Artist> >(RequestFactory.SearchArtistsRequest(text, Page, amount), (r, c) =>
                {
                    if (r.Succeeded())
                    {
                        artistPage = r.Data;
                        ShowSearchResults();
                    }
                    else
                    {
                        ApplicationViewModel.HandlExceptionResponse(r.ExceptionResponse());
                    }
                });

                /*Response<Page<Artist>> response = DataProvider.SearchArtistsByName(text, Page, amount);
                 * if (!response.Status)
                 * {
                 *  ApplicationViewModel.HandleError(response.Error);
                 *  return;
                 * }
                 * artistPage = response.Content;*/
            }
        }