protected override DriverResult Editor(WidgetPart widgetPart, IUpdateModel updater, dynamic shapeHelper) { updater.TryUpdateModel(widgetPart, Prefix, null, null); if (string.IsNullOrWhiteSpace(widgetPart.Title)) { updater.AddModelError("Title", T("Title can't be empty.")); } // if there is a name, ensure it's unique if (!string.IsNullOrWhiteSpace(widgetPart.Name)) { widgetPart.Name = widgetPart.Name.ToHtmlName(); var widgets = _contentManager.Query <WidgetPart, WidgetPartRecord>().Where(x => x.Name == widgetPart.Name && x.Id != widgetPart.Id).Count(); if (widgets > 0) { updater.AddModelError("Name", T("A Widget with the same Name already exists.")); } } _widgetsService.MakeRoomForWidgetPosition(widgetPart); return(Editor(widgetPart, shapeHelper)); }
protected override DriverResult Editor(WidgetPart widgetPart, IUpdateModel updater, dynamic shapeHelper) { updater.TryUpdateModel(widgetPart, Prefix, null, null); _widgetsService.MakeRoomForWidgetPosition(widgetPart); return(Editor(widgetPart, shapeHelper)); }
protected override DriverResult Editor(WidgetPart widgetPart, IUpdateModel updater, dynamic shapeHelper) { updater.TryUpdateModel(widgetPart, Prefix, null, null); if (string.IsNullOrWhiteSpace(widgetPart.Title)) { updater.AddModelError("Title", T("Title can't be empty.")); } // if there is a name, ensure it's unique if (!string.IsNullOrWhiteSpace(widgetPart.Name)) { widgetPart.Name = widgetPart.Name.ToHtmlName(); var widgets = _contentManager.Query <WidgetPart, WidgetPartRecord>().Where(x => x.Name == widgetPart.Name && x.Id != widgetPart.Id).Count(); if (widgets > 0) { updater.AddModelError("Name", T("A Widget with the same Name already exists.")); } } if (!String.IsNullOrEmpty(widgetPart.CssClasses)) { var classNames = widgetPart.CssClasses.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); for (var i = 0; i < classNames.Length; i++) { classNames[i] = classNames[i].Trim().HtmlClassify(); } widgetPart.CssClasses = String.Join(" ", classNames); } _widgetsService.MakeRoomForWidgetPosition(widgetPart); return(Editor(widgetPart, shapeHelper)); }