コード例 #1
0
ファイル: SearchViewModel.cs プロジェクト: yongjan/Audiotica
        public async Task SearchAsync(string term)
        {
            try
            {
                _tracksResponse = await _service.SearchTracksAsync(term);

                Tracks = CreateIncrementalCollection(
                    () => _tracksResponse,
                    tracks => _tracksResponse = tracks,
                    async i => await _service.SearchTracksAsync(term, i));
                foreach (var lastTrack in _tracksResponse)
                {
                    Tracks.Add(lastTrack);
                }

                _albumsResponse = await _service.SearchAlbumsAsync(term);

                Albums = CreateIncrementalCollection(
                    () => _albumsResponse,
                    albums => _albumsResponse = albums,
                    async i => await _service.SearchAlbumsAsync(term, i));
                foreach (var lastAlbum in _albumsResponse)
                {
                    Albums.Add(lastAlbum);
                }

                _artistsResponse = await _service.SearchArtistAsync(term);

                Artists = CreateIncrementalCollection(
                    () => _artistsResponse,
                    artists => _artistsResponse = artists,
                    async i => await _service.SearchArtistAsync(term, i));
                foreach (var lastArtist in _artistsResponse)
                {
                    Artists.Add(lastArtist);
                }

                //if (_tracksResponse.TotalItems == 0)
                //CurtainToast.ShowError("NoSearchResultsToast".FromLanguageResource());
            }
            catch (LastException ex)
            {
                CurtainToast.ShowError(ex.Message);
            }
            catch
            {
                CurtainToast.ShowError("NetworkIssueToast".FromLanguageResource());
            }
        }