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); }
public ActionResult PublicInfo(string widgetZone, object model) { //if (LicenseChecker.CheckState("SmartSite.CustomBanner", null) == null) //{ // return new EmptyResult(); //} int pictureId = 0; if (model != null) { int pageId = 0; string entity = ""; if (model.GetType() == typeof(ArticlePostModel)) { ArticlePostModel articleModel = (ArticlePostModel)model; pageId = articleModel.Id; entity = "article"; } else { if (model.GetType() == typeof(ArticleCategoryModel)) { ArticleCategoryModel categoryModel = (ArticleCategoryModel)model; pageId = categoryModel.Id; entity = "category"; } else { if (model.GetType() == typeof(TopicModel)) { TopicModel topicModel = (TopicModel)model; pageId = topicModel.Id; entity = "topic"; } } } CustomBannerRecord bannerRecord = this._customBannerService.GetCustomBannerRecord(pageId, entity); if (bannerRecord != null) { pictureId = bannerRecord.PictureId; } } if (pictureId != 0) { CustomBannerSettings customBannerSettings = this._settingService.LoadSetting <CustomBannerSettings>(this._siteContext.CurrentSite.Id); Picture pic = this._pictureService.GetPictureById(pictureId); return(base.View(new PublicInfoModel { PicturePath = this._pictureService.GetPictureUrl(pic, 0, true, null), MaxBannerHeight = customBannerSettings.MaxBannerHeight, StretchPicture = customBannerSettings.StretchPicture, ShowBorderBottom = customBannerSettings.ShowBorderBottom, ShowBorderTop = customBannerSettings.ShowBorderTop, BorderTopColor = customBannerSettings.BorderTopColor, BorderBottomColor = customBannerSettings.BorderBottomColor })); } return(base.Content("")); }
public void DeleteCustomBannerRecord(CustomBannerRecord record) { if (record == null) { throw new ArgumentNullException("record"); } this._cbRepository.Delete(record); }
public void InsertCustomBannerRecord(CustomBannerRecord record) { if (record == null) { throw new ArgumentNullException("CustomBannerRecord"); } this._cbRepository.Insert(record); }
public CustomBannerRecord GetCustomBannerRecord(int entityId, string entityName) { if (entityId == 0) { return(null); } CustomBannerRecord record = new CustomBannerRecord(); IQueryable <CustomBannerRecord> query = this._cbRepository.Table.Where(p => p.EntityId == entityId & p.EntityName == entityName); if (query.Count() > 0) { return(query.FirstOrDefault()); } return(null); }
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); }