diff --git a/src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs b/src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs index 52dbe549c2..dcf8f80290 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs @@ -298,7 +298,8 @@ namespace Umbraco.Web.Models.Mapping // Umbraco.Code.MapAll -CreateDate -UpdateDate -DeleteDate -Key -PropertyTypes private static void Map(PropertyGroupBasic source, PropertyGroup target, MapperContext context) { - target.Id = source.Id; + if (source.Id > 0) + target.Id = source.Id; target.Key = source.Key; target.Type = source.Type; target.Name = source.Name; @@ -309,7 +310,8 @@ namespace Umbraco.Web.Models.Mapping // Umbraco.Code.MapAll -CreateDate -UpdateDate -DeleteDate -Key -PropertyTypes private static void Map(PropertyGroupBasic source, PropertyGroup target, MapperContext context) { - target.Id = source.Id; + if (source.Id > 0) + target.Id = source.Id; target.Key = source.Key; target.Type = source.Type; target.Name = source.Name; @@ -321,7 +323,8 @@ namespace Umbraco.Web.Models.Mapping private static void Map(PropertyGroupBasic source, PropertyGroupDisplay target, MapperContext context) { target.Inherited = source.Inherited; - target.Id = source.Id; + if (source.Id > 0) + target.Id = source.Id; target.Key = source.Key; target.Type = source.Type; target.Name = source.Name; @@ -334,7 +337,8 @@ namespace Umbraco.Web.Models.Mapping private static void Map(PropertyGroupBasic source, PropertyGroupDisplay target, MapperContext context) { target.Inherited = source.Inherited; - target.Id = source.Id; + if (source.Id > 0) + target.Id = source.Id; target.Key = source.Key; target.Type = source.Type; target.Name = source.Name; @@ -461,7 +465,7 @@ namespace Umbraco.Web.Models.Mapping } // ensure no duplicate name, then assign the groups collection - EnsureUniqueNames(destGroups); + EnsureUniqueAliases(destGroups); target.PropertyGroups = new PropertyGroupCollection(destGroups); // because the property groups collection was rebuilt, there is no need to remove @@ -663,15 +667,15 @@ namespace Umbraco.Web.Models.Mapping throw new InvalidOperationException("Cannot map properties due to alias conflict."); } - private static void EnsureUniqueNames(IEnumerable groups) + private static void EnsureUniqueAliases(IEnumerable groups) { var groupsA = groups.ToArray(); var distinctProperties = groupsA - .Select(x => x.Name?.ToUpperInvariant()) + .Select(x => x.Alias) .Distinct() .Count(); if (distinctProperties != groupsA.Length) - throw new InvalidOperationException("Cannot map groups due to name conflict."); + throw new InvalidOperationException("Cannot map groups due to alias conflict."); } private static void MapComposition(ContentTypeSave source, IContentTypeComposition target, Func getContentType) diff --git a/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs b/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs index 85a3e56c4f..7818a7f892 100644 --- a/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs +++ b/src/Umbraco.Web/Models/Mapping/EntityMapDefinition.cs @@ -85,7 +85,7 @@ namespace Umbraco.Web.Models.Mapping // Umbraco.Code.MapAll -Udi -Trashed private static void Map(PropertyGroup source, EntityBasic target, MapperContext context) { - target.Alias = source.Name?.ToLowerInvariant(); + target.Alias = source.Alias; target.Icon = "icon-tab"; target.Id = source.Id; target.Key = source.Key;