public async Task <ActionResult <List <VideoDataset> > > GetSectionVideos([FromRoute] int cvId, [FromRoute] int sectionId, [FromRoute] int videoId) { if (await _cvService.GetCVSection(cvId, sectionId) == null) { return(NotFound()); } VideoDataset result = await _videoService.GetVideoById(videoId); if (result != null) { return(Ok(result)); } return(NotFound()); }
public async Task <ActionResult <VideoDataset> > CreateVideo([FromRoute] int cvId, [FromRoute] int sectionId, [FromRoute] int videoId) { VideoDataset video = await _videoService.GetVideoById(videoId); if (video == null) { return(NotFound()); } if (video.CVId != cvId || video.SectionId != sectionId) { return(Forbid()); } if (await _videoService.DeleteVideo(videoId)) { return(NoContent()); } return(BadRequest(new { message = "Deleting video failed" })); }
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" })); }