public void Patch(Guid id, PlaylistItemDto playlistItemDto) { using (ITransaction transaction = Session.BeginTransaction()) { PlaylistItem playlistItem = PlaylistItemManager.Get(id); playlistItemDto.SetPatchableProperties(playlistItem); PlaylistItemManager.Update(playlistItem); transaction.Commit(); } }
public PlaylistItemDto Create(PlaylistItemDto playlistItemDto) { PlaylistItemDto savedPlaylistItemDto; using (ITransaction transaction = Session.BeginTransaction()) { Playlist playlist = PlaylistManager.Get(playlistItemDto.PlaylistId); SongDto songDto = playlistItemDto.Song; PlaylistItem playlistItem = new PlaylistItem(playlistItemDto.Id, playlistItemDto.Title, playlistItemDto.Cid, songDto.Id, songDto.Type, songDto.Title, songDto.Duration, songDto.Author); playlistItemDto.SetPatchableProperties(playlistItem); playlist.AddItem(playlistItem); PlaylistItemManager.Save(playlistItem); savedPlaylistItemDto = PlaylistItemDto.Create(playlistItem); transaction.Commit(); } return(savedPlaylistItemDto); }