public async Task <IActionResult> DeleteVideo(int teacherId, int videoId) { string auth = Request.Headers["Authorization"]; // get bearer string if (AuthHelper.BasicAuth(auth, teacherId, "Teacher") == false) { return(Unauthorized()); } var videoToDelete = await _repo.GetVideo(videoId); if (videoToDelete != null) { if (videoToDelete.PublicId != null) { var delParam = new DeletionParams(videoToDelete.PublicId) { ResourceType = ResourceType.Video }; var delResResult = _cloudinary.Destroy(delParam); } await _repo.DeleteVideo(videoId); return(Ok()); } else { return(BadRequest("This course doesn't exist !!")); } }
public ActionResult Delete(int videoId) { Video video = repository.Videos.FirstOrDefault(v => v.VideoID == videoId); if (video != null) { repository.DeleteVideo(video); TempData["message"] = string.Format("{0} was deleted", video.Title); } return(RedirectToAction("Index")); }
public async Task <ActionResult <Video> > DeleteVideo(int id) { var video = await _videoRepository.GetVideoByID(id); if (video == null) { return(NotFound()); } bool deleted = await _videoRepository.DeleteVideo(id); if (!deleted) { return(BadRequest(new { message = "Failed to delete video" })); } return(Ok(new { message = "Video deleted" })); }
public async Task <IActionResult> Delete(Guid videoId) { if (videoId == Guid.Empty) { return(BadRequest()); } if (!_videoRepository.TryGetVideoById(videoId, out var video)) { return(NotFound()); } _videoRepository.DeleteVideo(video); if (!await _unitOfWork.CompleteWorkAsync()) { throw new Exception($"Error when deleting video: {videoId}"); } return(NoContent()); }
public ActionResult DeleteSection(int courseId, int sectionId) { if (!_courseRepository.CourseExists(courseId)) { return(NotFound()); } if (!_sectionRepository.SectionExists(sectionId)) { return(NotFound()); } var section = _sectionRepository.GetSection(sectionId); var course = _courseRepository.GetCourse(courseId); if (_videoRepository.GetAllVideosFromSection(sectionId).Count() > 0) { var videos = _videoRepository.GetAllVideosFromSection(sectionId); foreach (var video in videos) { if (!_videoRepository.DeleteVideo(video)) { return(BadRequest(ModelState)); } } } if (!_courseRepository.DeleteSectionOfACourse(section, course)) { ModelState.AddModelError("", $"Something went wrong!"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(NoContent()); }
public ActionResult DeleteVideo(int videoId) { if (!_videoRepository.VideoExists(videoId)) { return(NotFound()); } var video = _videoRepository.GetVideo(videoId); System.IO.File.Delete(Path.Combine(video.VideoPath)); if (!_videoRepository.DeleteVideo(video)) { ModelState.AddModelError("", $"Something went wrong!"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(NoContent()); }
public Video Delete(int id) { return(_videoRepository.DeleteVideo(id)); }
/// <summary> /// Delete Video by id /// </summary> /// <param name="id"></param> public void DeleteVideo(int id) { _videoRepository.DeleteVideo(id); }
public Video DeleteVideo(int id) { return(_videoRepo.DeleteVideo(id)); }