public ActionResult PictureEditTab(int entityId, string entityName)
        {
            if (!this._permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                return(base.AccessDeniedView());
            }
            this._settingService.LoadSetting <CustomBannerSettings>(this._siteContext.CurrentSite.Id);
            CustomBannerRecord customBannerRecord = new CustomBannerRecord();

            customBannerRecord = this._customBannerService.GetCustomBannerRecord(entityId, entityName);
            PictureEditTabModel model = new PictureEditTabModel();

            model.EntityId   = entityId;
            model.EntityName = entityName;
            if (customBannerRecord != null)
            {
                model.PictureId = customBannerRecord.PictureId;
            }
            PartialViewResult  result       = base.PartialView(model);
            ViewDataDictionary viewData     = result.ViewData;
            TemplateInfo       templateInfo = new TemplateInfo();

            templateInfo.HtmlFieldPrefix = "CustomProperties[CustomBanner]";
            viewData.TemplateInfo        = templateInfo;
            return(result);
        }
示例#2
0
        public void HandleEvent(ModelBoundEvent eventMessage)
        {
            if (!eventMessage.BoundModel.CustomProperties.ContainsKey("CustomBanner"))
            {
                return;
            }
            PictureEditTabModel model = eventMessage.BoundModel.CustomProperties["CustomBanner"] as PictureEditTabModel;

            if (model == null)
            {
                return;
            }
            if (!this._permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                return;
            }
            this._settingService.LoadSetting <CustomBannerSettings>(this._siteContext.CurrentSite.Id);
            DateTime           utcNow = DateTime.UtcNow;
            CustomBannerRecord entity = this._customBannerService.GetCustomBannerRecord(model.EntityId, model.EntityName);
            bool insert = entity == null;

            if (entity == null)
            {
                entity = new CustomBannerRecord
                {
                    EntityId     = model.EntityId,
                    EntityName   = model.EntityName,
                    CreatedOnUtc = utcNow
                };
            }
            entity.AddEntitySysParam(true, true);
            entity.PictureId = model.PictureId;
            if (insert)
            {
                this._customBannerService.InsertCustomBannerRecord(entity);
                return;
            }
            this._customBannerService.UpdateCustomBannerRecord(entity);
        }