public async Task <JsonResult> UpdateTypeContents() { var temp = this.DeserializeObject <IEnumerable <NewPartVM> >(); foreach (var item in temp) { ContentItem DevicesInfoContentItem = await _contentManager.GetAsync(item.NewID); DevicesInfoContentItem.Alter <NewPart>(x => x.NewDisplayName = item.NewDisplayName); DevicesInfoContentItem.Alter <NewPart>(x => x.NewDescription = item.NewDescription); DevicesInfoContentItem.Alter <NewPart>(x => x.Classify = item.Classify); item.Name = "ContentType_" + item.NewDisplayName; if (_contentDefinitionManager.GetTypeDefinition(item.Name) == null) { } else { if (item.Classify == false) { var BodyPartSetting = new BodyPartSettings { }; BodyPartSetting.Editor = "Wysiwyg"; _contentDefinitionManager.AlterTypeDefinition(item.Name, bulid => bulid .DisplayedAs(item.NewDisplayName) .Draftable() .Creatable() .Listable() .WithPart("TitlePart") .WithPart("BodyPart", part => part.WithSettings(BodyPartSetting)) ); } else { var BodyPartSetting = new BodyPartSettings { }; BodyPartSetting.Editor = "Wysiwyg"; _contentDefinitionManager.AlterTypeDefinition(item.Name, bulid => bulid .DisplayedAs(item.NewDisplayName) .Draftable() .Creatable() .Listable() .WithPart("TitlePart", part => part.WithPosition("2")) .WithPart("BodyPart", part => part.WithSettings(BodyPartSetting).WithPosition("3")) .WithPart("TypeNewClassifyPart", part => part.WithPosition("1")) ); } } DevicesInfoContentItem.Alter <NewPart>(x => x.Name = item.Name); DevicesInfoContentItem.Alter <TitlePart>(x => x.Title = item.NewDisplayName); _contentDefinitionManager.GetTypeDefinition(item.Name); _session.Save(DevicesInfoContentItem); } return(this.Jsonp(temp)); }
public override IEnumerable <TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel) { if (builder.Name != "PostPart") { yield break; } var model = new BodyPartSettings(); updateModel.TryUpdateModel(model, "PostPartSettings", null, null); builder.WithSetting("PostPartSettings.FlavorDefault", !string.IsNullOrWhiteSpace(model.FlavorDefault) ? model.FlavorDefault : null); yield return(DefinitionTemplate(model)); }