예제 #1
0
        /// <summary>
        ///     Create a new Playlist, save it to the DB, then generate N PlaylistItemDtos
        ///     which have the Playlist as their parent.
        /// </summary>
        public static List <PlaylistItemDto> CreatePlaylistItemsDto(int itemsToCreate, Guid playlistId = default(Guid))
        {
            if (playlistId == default(Guid))
            {
                User user = CreateUser();
                playlistId = user.Playlists.First().Id;
            }

            Video    video    = CreateUnsavedVideoWithId();
            VideoDto videoDto = VideoDto.Create(video);

            List <PlaylistItemDto> playlistItemDtos = new List <PlaylistItemDto>();

            for (int i = 0; i < itemsToCreate; i++)
            {
                var playlistItemDto = new PlaylistItemDto
                {
                    PlaylistId = playlistId,
                    Video      = videoDto
                };

                playlistItemDtos.Add(playlistItemDto);
            }

            return(playlistItemDtos);
        }
예제 #2
0
        public ActionResult Get(string id)
        {
            Video    video    = VideoDao.Get(id);
            VideoDto videoDto = VideoDto.Create(video);

            return(new JsonServiceStackResult(videoDto));
        }
예제 #3
0
        public ActionResult Get(string id)
        {
            Video    video    = VideoDao.Get(id);
            VideoDto videoDto = VideoDto.Create(video);

            return(new JsonDataContractActionResult(videoDto));
        }
예제 #4
0
        public ActionResult Update(VideoDto videoDto)
        {
            Video video = Video.Create(videoDto);

            VideoManager.Save(video);

            VideoDto savedVideoDto = VideoDto.Create(video);

            return(new JsonServiceStackResult(savedVideoDto));
        }
예제 #5
0
        public ActionResult Update(VideoDto videoDto)
        {
            Video video = Video.Create(videoDto);

            VideoManager.Save(video);

            VideoDto savedVideoDto = VideoDto.Create(video);

            return(new JsonDataContractActionResult(savedVideoDto));
        }
예제 #6
0
        public ActionResult GetByIds(List <string> ids)
        {
            var videoDtos = new List <VideoDto>();

            //  The default model binder doesn't support passing an empty array as JSON to MVC controller, so check null.
            if (ids != null)
            {
                IList <Video> videos = VideoDao.Get(ids);
                videoDtos = VideoDto.Create(videos);
            }

            return(new JsonServiceStackResult(videoDtos));
        }
예제 #7
0
        /// <summary>
        ///     Create a new Folder and Playlist, save them to the DB, then generate a PlaylistItemDto
        ///     which has those entities as its parents.
        /// </summary>
        public static PlaylistItemDto CreatePlaylistItemDto()
        {
            Guid playlistId = UserManager.CreateUser().Folders.First().Playlists.First().Id;

            Video    video    = CreateUnsavedVideoWithId();
            VideoDto videoDto = VideoDto.Create(video);

            var playlistItemDto = new PlaylistItemDto
            {
                PlaylistId = playlistId,
                Video      = videoDto
            };

            return(playlistItemDto);
        }
예제 #8
0
        /// <summary>
        ///     Create a new Playlist, save it to the DB, then generate a PlaylistItemDto
        ///     which has the Playlist as its parent.
        /// </summary>
        public PlaylistItemDto CreatePlaylistItemDto()
        {
            User user = CreateUser();

            Guid playlistId = user.Playlists.First().Id;

            Video    video    = CreateUnsavedVideoWithId();
            VideoDto videoDto = VideoDto.Create(video);

            var playlistItemDto = new PlaylistItemDto
            {
                PlaylistId = playlistId,
                Video      = videoDto
            };

            return(playlistItemDto);
        }