コード例 #1
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 _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));
            }
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <summary>
        /// Searches for releases with the entered <see cref="SearchText"/>.
        /// </summary>
        /// <returns>Task.</returns>
        private async Task SearchRelease()
        {
            try
            {
                OnStatusUpdated("Trying to search for release '" + SearchText + "'");

                FetchedReleases.Clear();

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

                if (FetchedReleases.Count != 0)
                {
                    FetchedReleaseThroughArtist = false;
                    CurrentView = _releaseResultView;
                    OnStatusUpdated("Found " + FetchedReleases.Count + " releases");
                }
                else
                {
                    OnStatusUpdated("Found no releases");
                }
            }
            catch (Exception ex)
            {
                OnStatusUpdated("Error while searching for release '" + SearchText + "': " + ex.Message);
            }
        }
コード例 #4
0
        /// <summary>
        /// Searches for releases with the entered <see cref="SearchText"/>.
        /// </summary>
        /// <returns>Task.</returns>
        private async Task SearchRelease()
        {
            try
            {
                OnStatusUpdated(string.Format("Trying to search for release '{0}'", SearchText));

                FetchedReleases.Clear();

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

                if (FetchedReleases.Count != 0)
                {
                    FetchedReleaseThroughArtist = false;
                    CurrentView = _releaseResultView;
                    OnStatusUpdated(string.Format("Found {0} releases", FetchedReleases.Count));
                }
                else
                {
                    OnStatusUpdated("Found no releases");
                }
            }
            catch (Exception ex)
            {
                OnStatusUpdated(string.Format("Fatal error while searching for release '{0}': {1}", SearchText, ex.Message));
            }
        }
コード例 #5
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 + "'");
            }
        }