/// <summary>
        /// Adds a new <see cref="FetchedReleaseViewModel"/> to the <see cref="FetchedReleases"/>.
        /// </summary>
        /// <param name="name">Name of the release.</param>
        /// <param name="artistName">Name of the artist.</param>
        /// <param name="mbid">Mbid of the release.</param>
        /// <param name="image">Image of the release.</param>
        private void AddReleaseViewModel(string name, string artistName, string mbid, Uri image)
        {
            FetchedReleaseViewModel vm = new FetchedReleaseViewModel(new Release(name, artistName, mbid, image));

            vm.ReleaseClicked += ReleaseClicked;
            FetchedReleases.Add(vm);
        }
        /// <summary>
        /// Fetches the release list of the clicked artist via Last.fm.
        /// </summary>
        /// <param name="artist"></param>
        /// <returns>Task.</returns>
        private async Task ArtistClickedLastFm(Artist artist)
        {
            var response = await _lastfmArtistAPI.GetTopAlbumsAsync(artist.Name, false, 1, MaxResults);

            if (response.Success && response.Status == LastResponseStatus.Successful)
            {
                FetchedReleases.Clear();
                foreach (var s in response.Content)
                {
                    FetchedReleaseViewModel vm = new FetchedReleaseViewModel(new Release(s.Name, s.ArtistName, s.Mbid, s.Images.Large));
                    vm.ReleaseClicked += ReleaseClicked;
                    FetchedReleases.Add(vm);
                }

                if (FetchedReleases.Count != 0)
                {
                    FetchedReleaseThroughArtist = true;
                    CurrentView = _releaseResultView;
                    OnStatusUpdated(string.Format("Successfully fetched releases from artist '{0}'", artist.Name));
                }
                else
                {
                    OnStatusUpdated(string.Format("Artist '{0} has no releases", artist.Name));
                }
            }
            else
            {
                OnStatusUpdated(string.Format("Error while fetching releases from artist '{0}': {1}", artist.Name, response.Status));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Fetches the release list of the clicked artist via Last.fm.
        /// </summary>
        /// <param name="artist"></param>
        /// <returns>Task.</returns>
        private async Task ArtistClickedLastFm(Artist artist)
        {
            var response = await MainViewModel.Client.Artist.GetTopAlbumsAsync(artist.Name, false, 1, MaxResults);

            if (response.Success)
            {
                FetchedReleases.Clear();
                foreach (var s in response.Content)
                {
                    FetchedReleaseViewModel vm = new FetchedReleaseViewModel(new Release(s.Name, s.ArtistName, s.Mbid, s.Images.Large));
                    vm.ReleaseClicked += ReleaseClicked;
                    FetchedReleases.Add(vm);
                }

                if (FetchedReleases.Count != 0)
                {
                    FetchedReleaseThroughArtist = true;
                    CurrentView = _releaseResultView;
                    OnStatusUpdated("Successfully fetched releases from '" + artist.Name + "'");
                }
                else
                {
                    OnStatusUpdated("'" + artist.Name + "'" + " has no releases");
                }
            }
            else
            {
                OnStatusUpdated("Error while fetching releases from '" + artist.Name + "'");
            }
        }