/// <summary>
        /// Searches for artists with the entered <see cref="SearchText"/>.
        /// </summary>
        /// <returns>Task.</returns>
        private async Task SearchArtist()
        {
            try
            {
                OnStatusUpdated(string.Format("Trying to search for artist '{0}'...", SearchText));

                FetchedArtists.Clear();

                if (DatabaseToSearch == Database.LastFm)
                {
                    await SearchArtistLastFm();
                }

                if (FetchedArtists.Count != 0)
                {
                    CurrentView = _artistResultView;
                    OnStatusUpdated(string.Format("Found {0} artists", FetchedArtists.Count));
                }
                else
                {
                    OnStatusUpdated("Found no artists");
                }
            }
            catch (Exception ex)
            {
                OnStatusUpdated(string.Format("Fatal error while searching for artist '{0}': {1}", SearchText, ex.Message));
            }
        }
        /// <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);
        }
Esempio n. 3
0
        /// <summary>
        /// Searches for artists with the entered <see cref="SearchText"/>.
        /// </summary>
        /// <returns>Task.</returns>
        private async Task SearchArtist()
        {
            try
            {
                OnStatusUpdated("Trying to search for artist '" + SearchText + "'...");

                FetchedArtists.Clear();

                if (DatabaseToSearch == Database.LastFm)
                {
                    await SearchArtistLastFm();
                }

                if (FetchedArtists.Count != 0)
                {
                    CurrentView = _artistResultView;
                    OnStatusUpdated("Found " + FetchedArtists.Count + " artists");
                }
                else
                {
                    OnStatusUpdated("Found no artists");
                }
            }
            catch (Exception ex)
            {
                OnStatusUpdated("Error while searching for artist '" + SearchText + "': " + ex.Message);
            }
        }