Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 4
0
        public void UpdateSequence(PlaylistItemDto playlistItemDto)
        {
            using (ITransaction transaction = Session.BeginTransaction())
            {
                PlaylistItemManager.UpdateSequence(playlistItemDto.Id, playlistItemDto.Sequence);

                transaction.Commit();
            }
        }
Ejemplo n.º 5
0
        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);
        }