Пример #1
0
        public virtual ActionResult NewsPictureUpdate(NewsItemModel.NewsPictureModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews))
            {
                return(AccessDeniedView());
            }

            var newsPicture = _newsService.GetNewsPictureById(model.Id);

            if (newsPicture == null)
            {
                throw new ArgumentException("No news picture found with the specified id");
            }

            var picture = _pictureService.GetPictureById(newsPicture.PictureId);

            if (picture == null)
            {
                throw new ArgumentException("No picture found with the specified id");
            }

            _pictureService.UpdatePicture(picture.Id,
                                          _pictureService.LoadPictureBinary(picture),
                                          picture.MimeType,
                                          picture.SeoFilename,
                                          model.OverrideAltAttribute,
                                          model.OverrideTitleAttribute);

            newsPicture.DisplayOrder = model.DisplayOrder;
            _newsService.UpdateNewsPicture(newsPicture);

            return(new NullJsonResult());
        }
Пример #2
0
        public ActionResult NewsPictureUpdate(NewsItemModel.NewsPictureModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews))
            {
                return(AccessDeniedView());
            }

            var newsPicture = _newsService.GetNewsPictureById(model.Id);

            if (newsPicture == null)
            {
                throw new ArgumentException("No news picture found with the specified id");
            }


            newsPicture.DisplayOrder = model.DisplayOrder;
            _newsService.UpdateNewsPicture(newsPicture);

            return(new NullJsonResult());
        }
Пример #3
0
        public virtual ActionResult NewsPictureList(DataSourceRequest command, int newsId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews))
            {
                return(AccessDeniedKendoGridJson());
            }

            var newsPictures      = _newsService.GetNewsPicturesByNewsId(newsId);
            var newsPicturesModel = newsPictures
                                    .Select(x =>
            {
                var picture = _pictureService.GetPictureById(x.PictureId);
                if (picture == null)
                {
                    throw new Exception("Picture cannot be loaded");
                }
                var m = new NewsItemModel.NewsPictureModel
                {
                    Id                     = x.Id,
                    NewsId                 = x.NewsId,
                    PictureId              = x.PictureId,
                    PictureUrl             = _pictureService.GetPictureUrl(picture),
                    OverrideAltAttribute   = picture.AltAttribute,
                    OverrideTitleAttribute = picture.TitleAttribute,
                    DisplayOrder           = x.DisplayOrder
                };
                return(m);
            })
                                    .ToList();

            var gridModel = new DataSourceResult
            {
                Data  = newsPicturesModel,
                Total = newsPicturesModel.Count
            };

            return(Json(gridModel));
        }