From c25d132185e35b6ca5db62a99cb8b8878d055ea2 Mon Sep 17 00:00:00 2001 From: Rikki Tooley Date: Wed, 1 Oct 2014 00:53:05 +0100 Subject: [PATCH] Added artist top tracks and artist top albums methods to GetArtistInfo in demo app --- .../IF.Lastfm.Demo.Apollo.csproj | 1 + .../Pages/ArtistApi/GetArtistInfo.xaml | 42 ++++++++++---- .../Pages/ArtistApi/GetArtistInfo.xaml.cs | 2 - .../ArtistApi/GetArtistInfoViewModel.cs | 56 ++++++++++++++++--- 4 files changed, 80 insertions(+), 21 deletions(-) diff --git a/src/IF.Lastfm.Demo.Apollo/IF.Lastfm.Demo.Apollo.csproj b/src/IF.Lastfm.Demo.Apollo/IF.Lastfm.Demo.Apollo.csproj index aa038fb..89c71a1 100644 --- a/src/IF.Lastfm.Demo.Apollo/IF.Lastfm.Demo.Apollo.csproj +++ b/src/IF.Lastfm.Demo.Apollo/IF.Lastfm.Demo.Apollo.csproj @@ -264,4 +264,5 @@ + \ No newline at end of file diff --git a/src/IF.Lastfm.Demo.Apollo/Pages/ArtistApi/GetArtistInfo.xaml b/src/IF.Lastfm.Demo.Apollo/Pages/ArtistApi/GetArtistInfo.xaml index 761da92..f9f06cb 100644 --- a/src/IF.Lastfm.Demo.Apollo/Pages/ArtistApi/GetArtistInfo.xaml +++ b/src/IF.Lastfm.Demo.Apollo/Pages/ArtistApi/GetArtistInfo.xaml @@ -29,20 +29,38 @@ - - - - + + + + - - - + - - - - - + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/IF.Lastfm.Demo.Apollo/Pages/ArtistApi/GetArtistInfo.xaml.cs b/src/IF.Lastfm.Demo.Apollo/Pages/ArtistApi/GetArtistInfo.xaml.cs index 034317a..6cbec69 100644 --- a/src/IF.Lastfm.Demo.Apollo/Pages/ArtistApi/GetArtistInfo.xaml.cs +++ b/src/IF.Lastfm.Demo.Apollo/Pages/ArtistApi/GetArtistInfo.xaml.cs @@ -1,8 +1,6 @@ using System; using System.ComponentModel; -using IF.Lastfm.Demo.Apollo.TestPages.ViewModels; using IF.Lastfm.Demo.Apollo.ViewModels.ArtistApi; -using IF.Lastfm.Demo.Apollo.ViewModels.TrackApi; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; diff --git a/src/IF.Lastfm.Demo.Apollo/ViewModels/ArtistApi/GetArtistInfoViewModel.cs b/src/IF.Lastfm.Demo.Apollo/ViewModels/ArtistApi/GetArtistInfoViewModel.cs index d69f72c..9b985e5 100644 --- a/src/IF.Lastfm.Demo.Apollo/ViewModels/ArtistApi/GetArtistInfoViewModel.cs +++ b/src/IF.Lastfm.Demo.Apollo/ViewModels/ArtistApi/GetArtistInfoViewModel.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; +using System.Collections.Generic; using System.Threading.Tasks; using Cimbalino.Phone.Toolkit.Services; using IF.Lastfm.Core.Api; @@ -16,6 +12,8 @@ public class GetArtistInfoViewModel : BaseViewModel private string _artistName; private Artist _artist; private bool _inProgress; + private IEnumerable _topTracks; + private IEnumerable _topAlbums; public string ArtistName { @@ -61,11 +59,43 @@ public bool InProgress } } + public IEnumerable TopTracks + { + get { return _topTracks; } + set + { + if (Equals(value, _topTracks)) + { + return; + } + _topTracks = value; + OnPropertyChanged(); + } + } + + public IEnumerable TopAlbums + { + get { return _topAlbums; } + set + { + if (Equals(value, _topAlbums)) + { + return; + } + _topAlbums = value; + OnPropertyChanged(); + } + } + + public GetArtistInfoViewModel() + { + ArtistName = "Ben Frost"; + } + public async Task GetInfo() { InProgress = true; - - + var appsettings = new ApplicationSettingsService(); var apikey = appsettings.Get("apikey"); var apisecret = appsettings.Get("apisecret"); @@ -85,6 +115,18 @@ public async Task GetInfo() { Artist = artist.Content; } + + var topAlbums = await artistApi.GetTopAlbumsForArtistAsync(ArtistName); + if (topAlbums.Success) + { + TopAlbums = topAlbums; + } + + var topTracks = await artistApi.GetTopTracksForArtistAsync(ArtistName); + if (topTracks.Success) + { + TopTracks = topTracks; + } } InProgress = false;