コード例 #1
0
        public ActionResult Update(PlaylistDto playlistDto)
        {
            Playlist playlist = Playlist.Create(playlistDto);
            PlaylistManager.Update(playlist);

            PlaylistDto updatedPlaylistDto = PlaylistDto.Create(playlist);
            return new JsonDataContractActionResult(updatedPlaylistDto);
        }
コード例 #2
0
ファイル: Helpers.cs プロジェクト: zeemEU/StreamusServer
        /// <summary>
        ///     Generate a PlaylistDto which has the User as its parent.
        /// </summary>
        /// <returns></returns>
        public PlaylistDto CreatePlaylistDto(Guid userIdOverride)
        {
            var playlistDto = new PlaylistDto
            {
                UserId = userIdOverride
            };

            return playlistDto;
        }
コード例 #3
0
        /// <summary>
        ///     Generate a PlaylistDto which has the User as its parent.
        /// </summary>
        /// <returns></returns>
        public static PlaylistDto CreatePlaylistDto(Guid userIdOverride)
        {
            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();

            var playlistDto = new PlaylistDto
                {
                    UserId = userIdOverride
                };

            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();

            return playlistDto;
        }
コード例 #4
0
        public ActionResult Create(PlaylistDto playlistDto)
        {
            Playlist playlist = Playlist.Create(playlistDto);
            playlist.Folder.AddPlaylist(playlist);

            //  Make sure the playlist has been setup properly before it is cascade-saved through the Folder.
            playlist.ValidateAndThrow();

            PlaylistManager.Save(playlist);

            PlaylistDto savedPlaylistDto = PlaylistDto.Create(playlist);

            return new JsonDataContractActionResult(savedPlaylistDto);
        }
コード例 #5
0
        public static Playlist Create(PlaylistDto playlistDto)
        {
            Playlist playlist = Mapper.Map<PlaylistDto, Playlist>(playlistDto);

            //  TODO: I could probably leverage backbone's CID property to have the items know of their playlist.
            //  If an unsaved playlist comes from the client with items already in it, the items will not know their playlist's ID.
            //  So, re-map to the playlist as appropriate.

            List<PlaylistItem> improperlyAddedItems = playlist.Items.Where(i => i.Playlist == null).ToList();
            improperlyAddedItems.ForEach(i => playlist.Items.Remove(i));

            playlist.AddItems(improperlyAddedItems);

            return playlist;
        }
コード例 #6
0
ファイル: Helpers.cs プロジェクト: hihihippp/Streamus
        /// <summary>
        ///     Create a new Folder, save it to the DB, then generate a PlaylistDto which has the
        ///     Folder as its parent. Creates a folder for the Playlist if no folderId provided.
        /// </summary>
        /// <returns></returns>
        public static PlaylistDto CreatePlaylistDto(Guid folderIdOverride = default(Guid))
        {
            if (folderIdOverride == default(Guid))
            {
                Folder folder = new Folder();
                FolderManager.Save(folder);
                folderIdOverride = folder.Id;
                
                //  Ensure folder is lazy-loaded by evicting to make sure this helper method doesn't have side-effects.
                NHibernateSessionManager.Instance.Evict(folder);
            }

            var playlistDto = new PlaylistDto
                {
                    FolderId = folderIdOverride
                };

            return playlistDto;
        }
コード例 #7
0
ファイル: Playlist.cs プロジェクト: zeemEU/StreamusServer
        public static Playlist Create(PlaylistDto playlistDto, IUserManager userManager, IPlaylistManager playlistManager)
        {
            Playlist playlist = new Playlist
                {
                    Id = playlistDto.Id,
                    Items = PlaylistItem.Create(playlistDto.Items, playlistManager),
                    Sequence = playlistDto.Sequence,
                    Title = playlistDto.Title,
                    User = userManager.Get(playlistDto.UserId)
                };

            //  TODO: This seems unnecessary...
            //  TODO: I could probably leverage backbone's CID property to have the items know of their playlist. Or maybe I should just enforce adding client-side before saving?
            //  If an unsaved playlist comes from the client with items already in it, the items will not know their playlist's ID.
            //  So, re-map to the playlist as appropriate.
            List<PlaylistItem> improperlyAddedItems = playlist.Items.Where(i => i.Playlist == null).ToList();
            improperlyAddedItems.ForEach(i => playlist.Items.Remove(i));
            playlist.AddItems(improperlyAddedItems);

            return playlist;
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        public static PlaylistDto Create(Playlist playlist)
        {
            PlaylistDto playlistDto = Mapper.Map <Playlist, PlaylistDto>(playlist);

            return(playlistDto);
        }
コード例 #10
0
        public JsonResult Update(PlaylistDto playlistDto)
        {
            PlaylistDto updatedPlaylistDto;

            using (ITransaction transaction = Session.BeginTransaction())
            {
                Playlist playlist = Playlist.Create(playlistDto, UserManager, PlaylistManager);
                PlaylistManager.Update(playlist);

                updatedPlaylistDto = PlaylistDto.Create(playlist);

                transaction.Commit();
            }

            return Json(updatedPlaylistDto);
        }
コード例 #11
0
        public ActionResult Update(PlaylistDto playlistDto)
        {
            Playlist playlist = Playlist.Create(playlistDto);
            PlaylistManager.Update(playlist);

            PlaylistDto updatedPlaylistDto = PlaylistDto.Create(playlist);
            return new JsonServiceStackResult(updatedPlaylistDto);
        }