diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml index b08b251dbc20..ffbc77c0365d 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml @@ -1477,6 +1477,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont Media Type saved Member Type saved Member Group saved + Another Member Group with the same name already exists Template not saved Please make sure that you do not have 2 templates with the same alias Template saved diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml index a7fe7244bd70..184c40239725 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml @@ -1488,6 +1488,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont Media Type saved Member Type saved Member Group saved + Another Member Group with the same name already exists Template not saved Please make sure that you do not have 2 templates with the same alias Template saved diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml index 30bab94a63d2..9ac12607ed13 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml @@ -1411,6 +1411,7 @@ Pour gérer votre site, ouvrez simplement le backoffice Umbraco et commencez à Type de média sauvegardé Type de membre sauvegardé Groupe de membres sauvegardé + Un autre groupe de membres existe déjà avec le même nom Modèle non sauvegardé Assurez-vous de ne pas avoir 2 modèles avec le même alias. Modèle sauvegardé diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/nl.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/nl.xml index 83c563d8326d..c8f39cf02081 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/nl.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/nl.xml @@ -1276,6 +1276,7 @@ Echter, Runway biedt een gemakkelijke basis om je snel op weg te helpen. Als je Mediatype opgeslagen Ledentype opgeslagen Ledengroep opgeslagen + Er bestaat al een andere ledengroep met dezelfde naam Sjabloon niet opgeslagen Controleer dat je geen 2 sjablonen met dezelfde naam hebt Sjabloon opgeslagen diff --git a/src/Umbraco.Web/Editors/MemberGroupController.cs b/src/Umbraco.Web/Editors/MemberGroupController.cs index 19adf17a2adf..c5754d2f555f 100644 --- a/src/Umbraco.Web/Editors/MemberGroupController.cs +++ b/src/Umbraco.Web/Editors/MemberGroupController.cs @@ -135,6 +135,19 @@ public MemberGroupDisplay GetEmpty() return Mapper.Map(item); } + public bool IsMemberGroupNameUnique(int id, string oldName, string newName) + { + if (newName == oldName) + return true; // name hasn't changed + + var service = Services.MemberGroupService; + var memberGroup = service.GetByName(newName); + if (memberGroup == null) + return true; // no member group found + + return memberGroup.Id == id; + } + public MemberGroupDisplay PostSave(MemberGroupSave saveModel) { var service = Services.MemberGroupService; @@ -146,16 +159,27 @@ public MemberGroupDisplay PostSave(MemberGroupSave saveModel) throw new HttpResponseException(HttpStatusCode.NotFound); } - memberGroup.Name = saveModel.Name; - service.Save(memberGroup); + if (IsMemberGroupNameUnique(memberGroup.Id, memberGroup.Name, saveModel.Name)) + { + memberGroup.Name = saveModel.Name; + service.Save(memberGroup); - var display = Mapper.Map(memberGroup); + var display = Mapper.Map(memberGroup); + display.AddSuccessNotification( + Services.TextService.Localize("speechBubbles", "memberGroupSavedHeader"), + string.Empty); - display.AddSuccessNotification( - Services.TextService.Localize("speechBubbles", "memberGroupSavedHeader"), - string.Empty); + return display; + } + else + { + var display = Mapper.Map(memberGroup); + display.AddErrorNotification( + Services.TextService.Localize("speechBubbles", "memberGroupNameDuplicate"), + string.Empty); - return display; + return display; + } } } }