/// <summary> /// Adds a new <see cref="FetchedArtistViewModel"/> to the <see cref="FetchedArtists"/>. /// </summary> /// <param name="name">Name of the artist.</param> /// <param name="mbid">Mbid of the artist.</param> /// <param name="image">Image of the artist.</param> private void AddArtistViewModel(string name, string mbid, Uri image) { FetchedArtistViewModel vm = new FetchedArtistViewModel(new Artist(name, mbid, image)); vm.ArtistClicked += ArtistClicked; FetchedArtists.Add(vm); }
/// <summary> /// Sarches the entered <see cref="SearchText"/>. /// And displays the info. /// </summary> /// <returns>Task.</returns> public async Task Search() { EnableControls = false; if (SearchType == SearchType.Artist) { OnStatusUpdated("Trying to search for artist '" + SearchText + "'..."); var response = await MainViewModel.Client.Artist.SearchAsync(SearchText); if (response.Success) { FetchedArtists.Clear(); foreach (var s in response.Content) { FetchedArtistViewModel vm = new FetchedArtistViewModel(s); vm.ArtistClicked += ArtistClicked; FetchedArtists.Add(vm); } if (FetchedArtists.Count != 0) { CurrentView = _artistResultView; OnStatusUpdated("Found " + FetchedArtists.Count + " artists"); } else OnStatusUpdated("Found no artists"); } else OnStatusUpdated("Error while searching for artist '" + SearchText + "'"); } else if (SearchType == SearchType.Release) { OnStatusUpdated("Trying to search for release '" + SearchText + "'"); var response = await MainViewModel.Client.Album.SearchAsync(SearchText); if (response.Success) { FetchedReleases.Clear(); foreach (var s in response.Content) { FetchedReleaseViewModel vm = new FetchedReleaseViewModel(s); vm.ReleaseClicked += ReleaseClicked; FetchedReleases.Add(vm); } if (FetchedReleases.Count != 0) { FetchedReleaseThroughArtist = false; CurrentView = _releaseResultView; OnStatusUpdated("Found " + FetchedArtists.Count + " releases"); } else OnStatusUpdated("Found no releases"); } else OnStatusUpdated("Error while searching for release '" + SearchText + "'"); } EnableControls = true; }