예제 #1
0
        public ActionResult DeleteProductVideo(int id)
        {
            if (!_permissionService.Authorize("ManageProducts"))
            {
                return(AccessDeniedView());
            }

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

            var videoRecord = _videoService.GetProductVideoByVideoId(id);

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

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