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.Sequence, playlistItemDto.Title, playlistItemDto.Cid, songDto.Id, songDto.Type, songDto.Title, songDto.Duration, songDto.Author); playlist.AddItem(playlistItem); PlaylistItemManager.Save(playlistItem); savedPlaylistItemDto = PlaylistItemDto.Create(playlistItem); transaction.Commit(); } return savedPlaylistItemDto; }
public static PlaylistItemDto Create(PlaylistItem playlistItem) { PlaylistItemDto playlistItemDto = Mapper.Map <PlaylistItem, PlaylistItemDto>(playlistItem); return(playlistItemDto); }
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 void UpdateSequence(PlaylistItemDto playlistItemDto) { using (ITransaction transaction = Session.BeginTransaction()) { PlaylistItemManager.UpdateSequence(playlistItemDto.Id, playlistItemDto.Sequence); transaction.Commit(); } }
public PlaylistItemDto Update(PlaylistItemDto playlistItemDto) { PlaylistItemDto updatedPlaylistItemDto; using (ITransaction transaction = Session.BeginTransaction()) { PlaylistItem playlistItem = PlaylistItemManager.Get(playlistItemDto.Id); playlistItem.Title = playlistItemDto.Title; playlistItem.Sequence = playlistItemDto.Sequence; PlaylistItemManager.Update(playlistItem); updatedPlaylistItemDto = PlaylistItemDto.Create(playlistItem); transaction.Commit(); } return updatedPlaylistItemDto; }
public void PatchPlaylistItem_SequenceProvided_SequenceModified() { PlaylistItemDto playlistItemDto = Helpers.CreatePlaylistItemDto(); var createdPlaylistItemDto = PlaylistItemController.Create(playlistItemDto); const double newSequence = 5; PlaylistItemDto patchedPlaylistItemDto = new PlaylistItemDto { Sequence = newSequence }; PlaylistItem playlistItem = PlaylistItemManager.Get(createdPlaylistItemDto.Id); PlaylistItemController.Patch(playlistItem.Id, patchedPlaylistItemDto); Assert.AreEqual(playlistItem.Sequence, newSequence); }