public void DeleteVideo(DeleteVideoBindingModel dvbm)
        {
            var videoToRemove = this.data.Videos.All().FirstOrDefault(x => x.Id == dvbm.Id);

            this.data.Videos.Remove(videoToRemove);
            this.data.SaveChanges();
        }
        public async Task <IActionResult> Delete([FromBody] DeleteVideoBindingModel model)
        {
            var pictureUrl = await this.videosService.GetUrlByIdAsync(model.Id);

            if (pictureUrl == null)
            {
                return(this.BadRequest(WebConstants.DeleteDownloadPictureEror));
            }

            var result = FileHelpers.Delete($"{this.RootPath}{pictureUrl}");

            if (!result)
            {
                return(this.BadRequest(WebConstants.DeleteDownloadPictureEror));
            }

            result = await this.videosService.DeleteAsync(model.Id);

            return(this.Json(new { success = result }));
        }
Example #3
0
 public ActionResult DeleteVideo(DeleteVideoBindingModel dvbm)
 {
     this.service.DeleteVideo(dvbm);
     return(Redirect($"/user/{dvbm.Owner}"));
 }