public LayoutPropertyPart CreateLayoutProperty(LayoutPropertyRecord layoutPropertyRecord) { var layoutProperty = GetLayoutPropertyByQueryid(layoutPropertyRecord.QueryPartRecord_id); if (layoutProperty == null) { var contentItem = _contentManager.New("LayoutProperty"); layoutProperty = contentItem.As<LayoutPropertyPart>(); layoutProperty.VisableTo = layoutPropertyRecord.VisableTo; layoutProperty.PageRowCount = layoutPropertyRecord.PageRowCount; layoutProperty.QueryPartRecord_id = layoutPropertyRecord.QueryPartRecord_id; _contentManager.Create(contentItem); } else { layoutProperty.VisableTo = layoutPropertyRecord.VisableTo; layoutProperty.PageRowCount = layoutPropertyRecord.PageRowCount; _contentManager.Publish(layoutProperty.ContentItem); } return layoutProperty; }
public void EditPost(int id, ProjectionEditViewModel viewModel, IEnumerable<string> pickedFileds) { if (pickedFileds == null) { pickedFileds = new List<string>(); } var projectionPart = _contentManager.Get<ProjectionPart>(id, VersionOptions.Latest); var queryId = projectionPart.Record.QueryPartRecord.Id; var queryPart = _contentManager.Get<QueryPart>(queryId, VersionOptions.Latest); //Post DisplayName queryPart.As<TitlePart>().Title = viewModel.DisplayName; //Post Selected Fields var layoutRecord = projectionPart.Record.LayoutRecord; layoutRecord.Properties.Clear(); string category = viewModel.Name + "ContentFields"; const string settingName = "CoeveryTextFieldSettings.IsDispalyField"; var allFields = _contentDefinitionManager.GetPartDefinition(viewModel.Name).Fields.ToList(); foreach (var property in pickedFileds) { var field = allFields.FirstOrDefault(c => c.Name == property); if (field == null) { continue; } var propertyRecord = new PropertyRecord { Category = category, Type = string.Format("{0}.{1}.", viewModel.Name, property), Description = field.DisplayName, Position = layoutRecord.Properties.Count, State = GetPropertyState(property), LinkToContent = field.Settings.ContainsKey(settingName) && bool.Parse(field.Settings[settingName]) }; layoutRecord.Properties.Add(propertyRecord); } layoutRecord.State = GetLayoutState(queryPart.Id, layoutRecord.Properties.Count, layoutRecord.Description); // sort queryPart.SortCriteria.Clear(); if (!string.IsNullOrEmpty(viewModel.SortedBy)) { var sortCriterionRecord = new SortCriterionRecord { Category = category, Type = viewModel.SortedBy, Position = queryPart.SortCriteria.Count, State = GetSortState(viewModel.SortedBy, viewModel.SortMode), Description = viewModel.SortedBy + " " + viewModel.SortMode }; queryPart.SortCriteria.Add(sortCriterionRecord); } // VisableTo and pageRowCount var layoutPropertyRecord = new LayoutPropertyRecord { VisableTo = viewModel.VisableTo, PageRowCount = viewModel.PageRowCount, QueryPartRecord_id = queryPart.Id }; _layoutPropertyService.CreateLayoutProperty(layoutPropertyRecord); }