public async Task <VideoDataset> InsertVideo(VideoUploadParam upload) { Models.Video video = new Models.Video() { SectionId = upload.SectionId, StyleId = upload.StyleId, AspectRatio = upload.AspectRatio, CoverUrl = upload.CoverUrl, ThumbUrl = upload.ThumbUrl, VideoUrl = upload.VideoUrl }; _uow.VideoRepository.Insert(video); if (await _uow.CommitAsync() > 0) { return(await GetVideoById(video.VideoId)); } return(null); }
public async Task <ActionResult <VideoDataset> > CreateVideo([FromRoute] int cvId, [FromRoute] int sectionId, [FromBody] VideoUploadParam video) { if (await _cvService.GetCVSection(cvId, sectionId) == null) { return(NotFound()); } if (video.SectionId != sectionId) { return(Forbid()); } VideoDataset result = await _videoService.InsertVideo(video); if (result != null) { return(Created("", result)); } return(BadRequest(new { message = "Upload video failed" })); }