Exemplo n.º 1
0
        public ActionResult DeleteBlogVideo(int id)
        {
            if (!_permissionService.Authorize("ManageBlogs"))
            {
                return(AccessDeniedView());
            }

            if (id == 0)
            {
                throw new Exception("Video id not found");
            }

            var videoRecord = _videoService.GetBlogVideoByVideoId(id);

            if (videoRecord != null)
            {
                _videoService.DeleteBlogVideo(videoRecord.Id);
            }
            else
            {
                var video = _videoService.GetVideoById(id);
                if (video != null)
                {
                    _pictureService.Delete(video.Id);
                }
            }

            SuccessNotification("Blog video deleted successfully");
            return(new JsonResult()
            {
                Data = true,
                ContentEncoding = Encoding.Default,
                ContentType = "application/json",
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                MaxJsonLength = int.MaxValue
            });
        }