diff --git a/src/Umbraco.Core/Models/ContentTypeBase.cs b/src/Umbraco.Core/Models/ContentTypeBase.cs index d2fd56f0b6..38676560b1 100644 --- a/src/Umbraco.Core/Models/ContentTypeBase.cs +++ b/src/Umbraco.Core/Models/ContentTypeBase.cs @@ -477,6 +477,15 @@ namespace Umbraco.Core.Models } } + /// + /// Removes a PropertyGroup from the current ContentType + /// + /// Name of the to remove + public void RemovePropertyGroup(string propertyGroupName) + { + PropertyGroups.RemoveItem(propertyGroupName); + } + /// /// Sets the ParentId from the lazy integer id /// diff --git a/src/Umbraco.Core/Models/IContentTypeBase.cs b/src/Umbraco.Core/Models/IContentTypeBase.cs index b0a671eff8..4c3adf83d7 100644 --- a/src/Umbraco.Core/Models/IContentTypeBase.cs +++ b/src/Umbraco.Core/Models/IContentTypeBase.cs @@ -64,6 +64,12 @@ namespace Umbraco.Core.Models /// Alias of the to remove void RemovePropertyType(string propertyTypeAlias); + /// + /// Removes a PropertyGroup from the current ContentType + /// + /// Name of the to remove + void RemovePropertyGroup(string propertyGroupName); + /// /// Sets the ParentId from the lazy integer id /// diff --git a/src/Umbraco.Core/Models/PropertyGroupCollection.cs b/src/Umbraco.Core/Models/PropertyGroupCollection.cs index ee73c3c7ea..facb5b9e5c 100644 --- a/src/Umbraco.Core/Models/PropertyGroupCollection.cs +++ b/src/Umbraco.Core/Models/PropertyGroupCollection.cs @@ -97,6 +97,14 @@ namespace Umbraco.Core.Models return this.Any(x => x.Name == groupName); } + public void RemoveItem(string propertyGroupName) + { + var key = IndexOfKey(propertyGroupName); + //Only removes an item if the key was found + if (key != -1) + RemoveItem(key); + } + public int IndexOfKey(string key) { for (var i = 0; i < this.Count; i++)