diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 38211cb0aa..fc473d729d 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -414,22 +414,17 @@ namespace Umbraco.Web.Editors { var result = new Dictionary(); - using (var scope = _scopeProvider.CreateScope()) - { - var contentTypes = Services.ContentTypeService.GetAll(contentTypeKeys).ToList(); + using var scope = _scopeProvider.CreateScope(autoComplete: true); + var contentTypes = Services.ContentTypeService.GetAll(contentTypeKeys).ToList(); - if (contentTypes.Any(contentType => contentType == null)) + foreach (var contentType in contentTypes) + { + if (contentType is null) { throw new HttpResponseException(HttpStatusCode.NotFound); } - foreach (var contentTypeKey in contentTypeKeys) - { - var contentType = contentTypes.First(c => c.Key == contentTypeKey); - result.Add(contentTypeKey, GetEmpty(contentType, parentId)); - } - - scope.Complete(); + result.Add(contentType.Key, GetEmpty(contentType, parentId)); } return result; diff --git a/src/Umbraco.Web/PropertyEditors/BlockEditorPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/BlockEditorPropertyEditor.cs index 22f1a7dd1a..0f9fa5a1d2 100644 --- a/src/Umbraco.Web/PropertyEditors/BlockEditorPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/BlockEditorPropertyEditor.cs @@ -156,15 +156,15 @@ namespace Umbraco.Web.PropertyEditors continue; } - if (!valEditors.ContainsKey(dataType.Id)) + if (!valEditors.TryGetValue(dataType.Id, out var valEditor)) { var tempConfig = dataType.Configuration; - var valEditor = propEditor.GetValueEditor(tempConfig); + valEditor = propEditor.GetValueEditor(tempConfig); valEditors.Add(dataType.Id, valEditor); } - var convValue = valEditors[dataType.Id].ToEditor(tempProp, dataTypeService); + var convValue = valEditor.ToEditor(tempProp, dataTypeService); // update the raw value since this is what will get serialized out row.RawPropertyValues[prop.Key] = convValue;