Throw a HTTP Bad Request if an API request in backoffice is made to try & delete the Default Language

This commit is contained in:
Warren
2018-03-27 16:33:28 +01:00
parent e5c7c5eb2d
commit e9380b048b

View File

@@ -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);
}