public PlaylistDto Create(PlaylistDto playlistDto) { PlaylistDto savedPlaylistDto; using (ITransaction transaction = Session.BeginTransaction()) { User user = UserManager.Get(playlistDto.UserId); Playlist playlist = new Playlist(playlistDto.Id); playlistDto.SetPatchableProperties(playlist); user.AddPlaylist(playlist); List <PlaylistItem> playlistItems = new List <PlaylistItem>(); foreach (PlaylistItemDto dto in playlistDto.Items) { PlaylistItem playlistItem = new PlaylistItem(dto.Id, dto.Title, dto.Cid, dto.Song.Id, dto.Song.Type, dto.Song.Title, dto.Song.Duration, dto.Song.Author); dto.SetPatchableProperties(playlistItem); playlistItems.Add(playlistItem); } playlist.AddItems(playlistItems); PlaylistManager.Save(playlist); savedPlaylistDto = PlaylistDto.Create(playlist); transaction.Commit(); } return(savedPlaylistDto); }
public void Updates() { Playlist playlist = User.CreateAndAddPlaylist(); PlaylistManager.Save(playlist); const string newTitle = "Existing Playlist 001"; PlaylistManager.UpdateTitle(playlist.Id, newTitle); Assert.AreEqual(playlist.Title, newTitle); }
public void DeletePlaylist() { // Create a new Playlist and write it to the database. string title = string.Format("New Playlist {0:D4}", User.Playlists.Count); var playlist = new Playlist(title); User.AddPlaylist(playlist); PlaylistManager.Save(playlist); // Now delete the created Playlist and ensure it is removed. PlaylistManager.Delete(playlist.Id); bool exceptionEncountered = false; try { Playlist deletedPlaylist = PlaylistManager.Get(playlist.Id); } catch (ObjectNotFoundException) { exceptionEncountered = true; } Assert.IsTrue(exceptionEncountered); }
public JsonResult Create(PlaylistDto playlistDto) { PlaylistDto savedPlaylistDto; using (ITransaction transaction = Session.BeginTransaction()) { Playlist playlist = Playlist.Create(playlistDto, UserManager, PlaylistManager); playlist.User.AddPlaylist(playlist); // Make sure the playlist has been setup properly before it is cascade-saved through the User. playlist.ValidateAndThrow(); PlaylistManager.Save(playlist); savedPlaylistDto = PlaylistDto.Create(playlist); transaction.Commit(); } return(Json(savedPlaylistDto)); }
public void SetupContext() { PlaylistItemManager = ManagerFactory.GetPlaylistItemManager(Session); PlaylistManager = ManagerFactory.GetPlaylistManager(Session); // Ensure that a User exists. User = Helpers.CreateUser(); // Make a new Playlist object each time to ensure no side-effects from previous test case. Playlist = User.CreateAndAddPlaylist(); PlaylistManager.Save(Playlist); }
private void Window_Closed(object sender, EventArgs e) { _libraryManager.Save(); _playlistManager.Save(); System.Windows.Application.Current.Shutdown(0); }
public void SetupContext() { // Make a new Playlist object each time to ensure no side-effects from previous test case. Playlist = User.CreateAndAddPlaylist(); PlaylistManager.Save(Playlist); }