public void RemoveSelectedPlaylistsAndFinish() { try { ServerPlaylists.RemovePlaylists(GetSelectedPlaylists()); UpdatePlaylists(false); NavigateBackToOverview(); } catch (NotConnectedException) { DisconnectedError(); } }
protected void UpdatePlaylists(bool create) { if (!_updateReadyEvent.WaitOne(Consts.TS_WAIT_FOR_PLAYLISTS_UPDATE)) { return; } try { ItemsList playlistsList; lock (_syncObj) { if (_playlists == null && !create) { // Can happen for example on async updates of the server's set of playlists return; } if (create) { _playlists = new ItemsList(); } playlistsList = _playlists; } List <PlaylistBase> serverPlaylists = new List <PlaylistBase>(); try { if (IsHomeServerConnected) { CollectionUtils.AddAll(serverPlaylists, ServerPlaylists.GetPlaylists()); } } catch (NotConnectedException) { } int numPlaylists = serverPlaylists.Count; UpdatePlaylists(playlistsList, serverPlaylists, numPlaylists == 1); IsPlaylistsSelected = numPlaylists == 1; } finally { _updateReadyEvent.Set(); } }
public void SavePlaylistAndFinish() { PlaylistRawData playlistData = (PlaylistRawData)_playlist; IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); try { if (ServerPlaylists.GetPlaylists().Any(p => p.Name == playlistData.Name)) { SaveFailed(LocalizationHelper.Translate(Consts.RES_SAVE_PLAYLIST_FAILED_PLAYLIST_ALREADY_EXISTS, playlistData.Name)); } else { ServerPlaylists.SavePlaylist(playlistData); _message = LocalizationHelper.Translate(Consts.RES_SAVE_PLAYLIST_SUCCESSFUL_TEXT, playlistData.Name); workflowManager.NavigatePush(Consts.WF_STATE_ID_PLAYLIST_SAVE_SUCCESSFUL); } } catch (Exception e) { SaveFailed(LocalizationHelper.Translate(Consts.RES_SAVE_PLAYLIST_FAILED_TEXT, e.Message)); } }