/// <summary> /// Saves this playlist data. If it does not exist, it will be created; otherwise, /// it will be updated. /// </summary> /// <param name="onSuccess">On success</param> /// <param name="onFailure">On failure</param> /// <param name="onError">On error</param> public void Save(Action <Playlist> onSuccess, Action <NetworkResponse> onFailure, Action onError) { var playlistData = new { playlist_id = PlaylistId, account_id = AccountId, name = Name }; if (PlaylistId == 0) { RestSharpTools.PostAsync <Playlist>("/playlist", playlistData, JSON_EQUIVALENTS, (response) => { onSuccess(response.Model); }, onFailure, () => { Console.WriteLine("Exception@Playlist->Save()"); onError?.Invoke(); }); } else { RestSharpTools.PutAsync <Playlist>("/playlist/" + PlaylistId, playlistData, JSON_EQUIVALENTS, (response) => { onSuccess(response.Model); }, onFailure, () => { Console.WriteLine("Exception@Playlist->Save()"); onError?.Invoke(); }); } }