// Umbraco.Code.MapAll -CreateDate -DeleteDate -UpdateDate // Umbraco.Code.MapAll -SupportsPublishing -Key -PropertyEditorAlias -ValueStorageType -Variations private static void Map(PropertyTypeBasic source, IPropertyType target, MapperContext context) { target.Name = source.Label; target.DataTypeId = source.DataTypeId; target.DataTypeKey = source.DataTypeKey; target.Mandatory = source.Validation.Mandatory; target.MandatoryMessage = source.Validation.MandatoryMessage; target.ValidationRegExp = source.Validation.Pattern; target.ValidationRegExpMessage = source.Validation.PatternMessage; target.SetVariesBy(ContentVariation.Culture, source.AllowCultureVariant); target.SetVariesBy(ContentVariation.Segment, source.AllowSegmentVariant); if (source.Id > 0) { target.Id = source.Id; } if (source.GroupId > 0) { target.PropertyGroupId = new Lazy <int>(() => source.GroupId, false); } target.Alias = source.Alias; target.Description = source.Description; target.SortOrder = source.SortOrder; target.LabelOnTop = source.LabelOnTop; }
public IActionResult EnableDocTypeSegments(string alias, string propertyTypeAlias) { if (_testDataSettings.Value.Enabled != true) { return(HttpNotFound()); } IContentType ct = Services.ContentTypeService.Get(alias); if (ct == null) { return(Content($"No document type found by alias {alias}")); } IPropertyType propType = ct.PropertyTypes.FirstOrDefault(x => x.Alias == propertyTypeAlias); if (propType == null) { return(Content($"The document type {alias} does not have a property type {propertyTypeAlias ?? "null"}")); } if (ct.Variations.VariesBySegment()) { return(Content($"The document type {alias} already allows segments, nothing has been changed")); } ct.SetVariesBy(ContentVariation.Segment); propType.SetVariesBy(ContentVariation.Segment); Services.ContentTypeService.Save(ct); return(Content($"The document type {alias} and property type {propertyTypeAlias} now allows segments")); }