private void SavePropertyType(SaveClickEventArgs e, IContentTypeComposition contentTypeItem) { this.CreateChildControls(); //The GenericPropertyWrapper control, which contains the details for the PropertyType being added GenericProperty gpData = gp.GenricPropertyControl; if (string.IsNullOrEmpty(gpData.Name.Trim()) == false && string.IsNullOrEmpty(gpData.Alias.Trim()) == false) { var propertyTypeAlias = Casing.SafeAliasWithForcingCheck(gpData.Alias.Trim()); if (contentTypeItem.PropertyTypeExists(propertyTypeAlias) == false) { //Find the DataTypeDefinition that the PropertyType should be based on var dataTypeDefinition = ApplicationContext.Current.Services.DataTypeService.GetDataTypeDefinitionById(gpData.Type); var propertyType = new PropertyType(dataTypeDefinition) { Alias = propertyTypeAlias, Name = gpData.Name.Trim(), Mandatory = gpData.Mandatory, ValidationRegExp = gpData.Validation, Description = gpData.Description }; //gpData.Tab == 0 Generic Properties / No Group if (gpData.Tab == 0) { contentTypeItem.AddPropertyType(propertyType); } else { //Find the PropertyGroup by its Id and then set the PropertyType on that group var exists = contentTypeItem.CompositionPropertyGroups.Any(x => x.Id == gpData.Tab); if (exists) { var propertyGroup = contentTypeItem.CompositionPropertyGroups.First(x => x.Id == gpData.Tab); contentTypeItem.AddPropertyType(propertyType, propertyGroup.Name); } else { var tab = gpData.Tabs.FirstOrDefault(x => x.Id == gpData.Tab); if (tab != null) { var caption = tab.GetRawCaption(); contentTypeItem.AddPropertyType(propertyType, caption); } } } gpData.Clear(); } else { e.Message = ui.Text("contentTypeDublicatePropertyType"); e.IconType = BasePage.speechBubbleIcon.warning; } } }