Ejemplo n.º 1
0
 /// <summary>
 /// Fetches all songs whose name starts with the given title.
 /// </summary>
 /// <param name="title">Song title</param>
 /// <param name="onSuccess">On success</param>
 /// <param name="onFailure">On failure</param>
 /// <param name="onError">On error</param>
 public static void FetchByTitleCoincidences(
     string title, Action <List <Song> > onSuccess, Action <NetworkResponse> onFailure, Action onError
     )
 {
     RestSharpTools.GetAsyncMultiple <Song>("/song/search/" + title, null, JSON_EQUIVALENTS, (response) => {
         if (response.Model.Count == 0)
         {
             onSuccess(response.Model);
             return;
         }
         foreach (var song in response.Model)
         {
             Album.FetchById(song.AlbumId, (album) => {
                 song.Album = album;
                 Genre.FetchById(song.GenreId, (genre) => {
                     song.Genre = genre;
                     song.FetchArtists(() => {
                         onSuccess(response.Model);
                     }, null, null);
                 }, null, null);
             }, null, null);
         }
     }, onFailure, () => {
         Console.WriteLine("Exception@Song->FetchByTitleCoincidences()");
         onError?.Invoke();
     });
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Fetches all genres.
 /// </summary>
 /// <param name="onSuccess">On success</param>
 /// <param name="onFailure">On failure</param>
 /// <param name="onError">On error</param>
 public static void FetchAll(Action <List <Genre> > onSuccess, Action <NetworkResponse> onFailure, Action onError)
 {
     RestSharpTools.GetAsyncMultiple <Genre>("/genres", null, JSON_EQUIVALENTS, (response) => {
         onSuccess(response.Model);
     }, onFailure, () => {
         onError?.Invoke();
         Console.WriteLine("Exception@Genre->FetchAll()");
     });
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Fetches all account playlists.
 /// </summary>
 /// <param name="accountId">Account ID</param>
 /// <param name="onSuccess">On success</param>
 /// <param name="onFailure">On failure</param>
 /// <param name="onError">On error</param>
 public static void FetchByAccountId(int accountId, Action <List <Playlist> > onSuccess, Action <NetworkResponse> onFailure, Action onError)
 {
     RestSharpTools.GetAsyncMultiple <Playlist>("/account/" + accountId + "/playlists", null, JSON_EQUIVALENTS, (response) => {
         onSuccess(response.Model);
     }, onFailure, () => {
         Console.WriteLine("Exception@Playlist->FetchByAccountId()");
         onError?.Invoke();
     });
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Fetches this song artists.
 /// </summary>
 /// <param name="onSuccess">On success</param>
 /// <param name="onFailure">On failure</param>
 /// <param name="onError">On error</param>
 public void FetchArtists(Action onSuccess, Action <NetworkResponse> onFailure, Action onError)
 {
     RestSharpTools.GetAsyncMultiple <Artist>("/song/" + SongId + "/artists", null, Artist.JSON_EQUIVALENTS, (response) => {
         this.Artists = response.Model;
         onSuccess();
     }, onFailure, () => {
         Console.WriteLine("Exception@Album->FetchArtists()");
         onError?.Invoke();
     });
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Fetches an artist by its starting artistic name.
 /// </summary>
 /// <param name="artisticName">Artist artistic name</param>
 /// <param name="onSuccess">On success</param>
 /// <param name="onFailure">On failure</param>
 /// <param name="onError">On error</param>
 public static void FetchByArtisticNameCoincidences(
     string artisticName, Action <List <Artist> > onSuccess, Action <NetworkResponse> onFailure, Action onError
     )
 {
     RestSharpTools.GetAsyncMultiple <Artist>("/artist/search/" + artisticName, null, JSON_EQUIVALENTS, (response) => {
         onSuccess(response.Model);
     }, onFailure, () => {
         Console.WriteLine("Exception@Artist->FetchByArtisticNameCoincidences()");
         onError?.Invoke();
     });
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Fetches all account songs of this account.
 /// </summary>
 /// <param name="onSuccess">On success</param>
 /// <param name="onFailure">On failure</param>
 /// <param name="onError">On error</param>
 public void FetchAccountSongs(Action onSuccess, Action <NetworkResponse> onFailure, Action onError)
 {
     RestSharpTools.GetAsyncMultiple <AccountSong>(
         "/account/" + AccountId + "/accountsongs", null,
         AccountSong.JSON_EQUIVALENTS,
         (response) => {
         this.AccountSongs = response.Model;
         onSuccess?.Invoke();
     }, (errorResponse) => {
         onFailure?.Invoke(errorResponse);
     }, () => {
         Console.WriteLine("Exception@Account->FetchAccountSongs()");
         onError?.Invoke();
     }
         );
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Fetches all songs attached to this genre.
 /// </summary>
 /// <param name="onSuccess">On success</param>
 /// <param name="onFailure">On failure</param>
 /// <param name="onError">On error</param>
 public void FetchSongs(Action <List <Song> > onSuccess, Action <NetworkResponse> onFailure, Action onError)
 {
     RestSharpTools.GetAsyncMultiple <Song>("/genre/" + GenreId + "/songs", null, Song.JSON_EQUIVALENTS, (response) => {
         List <Song> songs = response.Model;
         foreach (var song in songs)
         {
             Album.FetchById(song.AlbumId, (album) => {
                 song.Album = album;
                 Genre.FetchById(song.GenreId, (genre) => {
                     song.Genre = genre;
                     song.FetchArtists(() => {
                         onSuccess(songs);
                     }, null, null);
                 }, null, null);
             }, null, null);
         }
     }, onFailure, () => {
         onError?.Invoke();
         Console.WriteLine("Exception@Playlist->FetchSongs()");
     });
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Fetches an album by its starting name.
 /// </summary>
 /// <param name="name">Album name</param>
 /// <param name="onSuccess">On success</param>
 /// <param name="onFailure">On failure</param>
 /// <param name="onError">On error</param>
 public static void FetchByNameCoincidences(
     string name, Action <List <Album> > onSuccess, Action <NetworkResponse> onFailure, Action onError
     )
 {
     RestSharpTools.GetAsyncMultiple <Album>("/album/search/" + name, null, JSON_EQUIVALENTS, (response) => {
         if (response.Model.Count == 0)
         {
             onSuccess(response.Model);
             return;
         }
         foreach (var album in response.Model)
         {
             album.FetchArtists(() => {
                 onSuccess(response.Model);
             }, null, null);
         }
     }, (errorResponse) => {
         onFailure?.Invoke(errorResponse);
     }, () => {
         Console.WriteLine("Exception@Album->FetchByNameCoincidences()");
         onError?.Invoke();
     });
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Fetches all this album songs.
 /// </summary>
 /// <param name="onSuccess">On success</param>
 /// <param name="onFailure">On failure</param>
 /// <param name="onError">On error</param>
 public void FetchSongs(Action onSuccess, Action <NetworkResponse> onFailure, Action onError)
 {
     RestSharpTools.GetAsyncMultiple <Song>(
         "/album/" + AlbumId + "/songs", null, Song.JSON_EQUIVALENTS,
         (response) => {
         this.Songs = response.Model;
         foreach (var song in Songs)
         {
             song.Album = this;
             Genre.FetchById(song.GenreId, (genre) => {
                 song.Genre = genre;
                 song.FetchArtists(() => {
                     onSuccess();
                 }, null, null);
             }, null, null);
         }
     }, (errorResponse) => {
         onFailure?.Invoke(errorResponse);
     }, () => {
         Console.WriteLine("Exception@Album->FetchSongs()");
         onError?.Invoke();
     }
         );
 }