protected override DriverResult Editor(ColumnPart part, IUpdateModel updater, dynamic shapeHelper) { var model = new EditColumnPartViewModel(); updater.TryUpdateModel(model, Prefix, null, null); if (part.ContentItem.Id != 0) { ColumnService.UpdateForContentItem(part.ContentItem, model); } return(Editor(part, shapeHelper)); }
public void UpdateForContentItem(ContentItem item, EditColumnPartViewModel viewModel) { var part = item.As <ColumnPart>(); part.CallIndex = viewModel.CallIndex; part.Groups = viewModel.Groups; part.Sort = viewModel.Sort; part.ImageUrl = viewModel.ImageUrl; part.LinkUrl = viewModel.LinkUrl; part.Summary = viewModel.Summary; part.ParentId = viewModel.ParentId; if (IsContainNode(part.Id, part.ParentId)) { var oldEntity = TomeltServices.ContentManager.Get <ColumnPart>(part.Id, VersionOptions.Latest); var treePath = "," + part.ParentId + ","; var layer = 1; if (oldEntity.ParentId > 0) { var oldParentEntity = TomeltServices.ContentManager.Get <ColumnPart>(oldEntity.ParentId, VersionOptions.Latest); treePath = oldParentEntity.TreePath + part.ParentId + ","; layer = oldParentEntity.Layer + 1; } var temp = TomeltServices.ContentManager.Get <ColumnPart>(part.ParentId, VersionOptions.Latest); temp.TreePath = treePath; temp.Layer = layer; temp.ParentId = oldEntity.ParentId; UpdateChilds(part.ParentId); } if (part.ParentId > 0) { var entity = TomeltServices.ContentManager.Get <ColumnPart>(part.ParentId, VersionOptions.Latest); part.TreePath = entity.TreePath + part.Id + ","; part.Layer = entity.Layer + 1; } else { part.TreePath = "," + part.Id + ","; part.Layer = 1; } var newEntity = TomeltServices.ContentManager.Get <ColumnPart>(part.Id, VersionOptions.Latest); newEntity.TreePath = part.TreePath; newEntity.Layer = part.Layer; UpdateChilds(part.Id); ColumnRepository.Flush(); }