/// <summary> /// Get a list of all DocTypes which contain a property of a specified Alias /// </summary> /// <param name="PropertyAlias"></param> /// <returns></returns> public List <PropertyDoctypeInfo> GetDocTypesForProperty(string PropertyAlias) { var docTypesList = new List <PropertyDoctypeInfo>(); var allDocTypes = _services.ContentTypeService.GetAllContentTypes(); foreach (var docType in allDocTypes) { var matchingProps = docType.CompositionPropertyTypes.Where(n => n.Alias == PropertyAlias).ToList(); if (matchingProps.Any()) { foreach (var prop in matchingProps) { var x = new PropertyDoctypeInfo(); x.DocTypeAlias = docType.Alias; var matchingGroups = docType.PropertyGroups.Where(n => n.PropertyTypes.Contains(prop.Alias)).ToList(); if (matchingGroups.Any()) { x.GroupName = matchingGroups.First().Name; } docTypesList.Add(x); } } } return(docTypesList); }
public SiteAuditableProperties AllProperties() { var allProps = new SiteAuditableProperties(); allProps.PropsForDoctype = "[All]"; List <AuditableProperty> propertiesList = new List <AuditableProperty>(); var allDocTypes = _services.ContentTypeService.GetAllContentTypes(); foreach (var docType in allDocTypes) { //var ct = _services.ContentTypeService.Get(docTypeAlias); foreach (var prop in docType.PropertyTypes) { //test for the same property already in list if (propertiesList.Exists(i => i.UmbPropertyType.Alias == prop.Alias & i.UmbPropertyType.Name == prop.Name & i.UmbPropertyType.DataTypeId == prop.DataTypeId)) { //Add current DocType to existing property var info = new PropertyDoctypeInfo(); info.Id = docType.Id; info.DocTypeAlias = docType.Alias; info.GroupName = ""; propertiesList.Find(i => i.UmbPropertyType.Alias == prop.Alias).AllDocTypes.Add(info); } else { //Add new property AuditableProperty auditProp = PropertyTypeToAuditableProperty(prop); var info = new PropertyDoctypeInfo(); info.DocTypeAlias = docType.Alias; info.GroupName = ""; auditProp.AllDocTypes.Add(info); propertiesList.Add(auditProp); } } } allProps.AllProperties = propertiesList; return(allProps); }
/// <summary> /// Get a list of all DocTypes which contain a property of a specified Alias /// </summary> /// <param name="PropertyAlias"></param> /// <returns></returns> public static List <PropertyDoctypeInfo> GetDocTypesForProperty(string PropertyAlias) { var docTypesList = new List <PropertyDoctypeInfo>(); var allDocTypes = umbContentTypeService.GetAllContentTypes(); foreach (var docType in allDocTypes) { var matchingProps = docType.PropertyTypes.Where(n => n.Alias == PropertyAlias); if (matchingProps.Any()) { foreach (var prop in matchingProps) { var x = new PropertyDoctypeInfo(); x.DocTypeAlias = docType.Alias; // x.Id = prop.Id; x.GroupName = docType.PropertyGroups.First(n => n.PropertyTypes.Contains(prop)).Name; docTypesList.Add(x); } } } return(docTypesList); }