From e9380b048b9d68ba3d0bb7d1fb747a7b0a0cbb67 Mon Sep 17 00:00:00 2001 From: Warren Date: Tue, 27 Mar 2018 16:33:28 +0100 Subject: [PATCH] Throw a HTTP Bad Request if an API request in backoffice is made to try & delete the Default Language --- src/Umbraco.Web/Editors/LanguageController.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Editors/LanguageController.cs b/src/Umbraco.Web/Editors/LanguageController.cs index 20932f6bf9..c6e3dcfb2e 100644 --- a/src/Umbraco.Web/Editors/LanguageController.cs +++ b/src/Umbraco.Web/Editors/LanguageController.cs @@ -1,6 +1,9 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Net; +using System.Net.Http; using System.Web.Http; using Umbraco.Core.Persistence; using Umbraco.Web.Models; @@ -56,6 +59,13 @@ namespace Umbraco.Web.Editors { throw new EntityNotFoundException(id, $"Could not find language by id: '{id}'."); } + + if (language.IsDefaultVariantLanguage) + { + var message = $"Language with id '{id}' is currently set to 'default' and can not be deleted."; + throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, message)); + } + Services.LocalizationService.Delete(language); }