/// <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); }
public ActionResult Get(string id) { Video video = VideoDao.Get(id); VideoDto videoDto = VideoDto.Create(video); return(new JsonServiceStackResult(videoDto)); }
public ActionResult Get(string id) { Video video = VideoDao.Get(id); VideoDto videoDto = VideoDto.Create(video); return(new JsonDataContractActionResult(videoDto)); }
public ActionResult Update(VideoDto videoDto) { Video video = Video.Create(videoDto); VideoManager.Save(video); VideoDto savedVideoDto = VideoDto.Create(video); return(new JsonServiceStackResult(savedVideoDto)); }
public ActionResult Update(VideoDto videoDto) { Video video = Video.Create(videoDto); VideoManager.Save(video); VideoDto savedVideoDto = VideoDto.Create(video); return(new JsonDataContractActionResult(savedVideoDto)); }
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)); }
/// <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); }
/// <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); }