diff --git a/src/Umbraco.Cms.Api.Management/Controllers/Document/ByKeyDocumentController.cs b/src/Umbraco.Cms.Api.Management/Controllers/Document/ByKeyDocumentController.cs index 1644eac84b..be7d64bf97 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/Document/ByKeyDocumentController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/Document/ByKeyDocumentController.cs @@ -9,12 +9,12 @@ namespace Umbraco.Cms.Api.Management.Controllers.Document; public class ByKeyDocumentController : DocumentControllerBase { - private readonly IContentService _contentService; + private readonly IContentEditingService _contentEditingService; private readonly IDocumentViewModelFactory _documentViewModelFactory; - public ByKeyDocumentController(IContentService contentService, IDocumentViewModelFactory documentViewModelFactory) + public ByKeyDocumentController(IContentEditingService contentEditingService, IDocumentViewModelFactory documentViewModelFactory) { - _contentService = contentService; + _contentEditingService = contentEditingService; _documentViewModelFactory = documentViewModelFactory; } @@ -24,8 +24,7 @@ public class ByKeyDocumentController : DocumentControllerBase [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task ByKey(Guid key) { - // FIXME: create and use an async get method here. - IContent? content = _contentService.GetById(key); + IContent? content = await _contentEditingService.GetAsync(key); if (content == null) { return NotFound(); diff --git a/src/Umbraco.Core/Services/ContentEditingService.cs b/src/Umbraco.Core/Services/ContentEditingService.cs index 8f3ff37251..39928580c6 100644 --- a/src/Umbraco.Core/Services/ContentEditingService.cs +++ b/src/Umbraco.Core/Services/ContentEditingService.cs @@ -29,6 +29,12 @@ internal sealed class ContentEditingService _scopeProvider = scopeProvider; } + public async Task GetAsync(Guid id) + { + IContent? content = ContentService.GetById(id); + return await Task.FromResult(content); + } + public async Task> CreateAsync(ContentCreateModel createModel, int userId) { Attempt result = await MapCreate(createModel); diff --git a/src/Umbraco.Core/Services/IContentEditingService.cs b/src/Umbraco.Core/Services/IContentEditingService.cs index 3c386dd924..c38e15f436 100644 --- a/src/Umbraco.Core/Services/IContentEditingService.cs +++ b/src/Umbraco.Core/Services/IContentEditingService.cs @@ -6,6 +6,8 @@ namespace Umbraco.Cms.Core.Services; public interface IContentEditingService { + Task GetAsync(Guid id); + Task> CreateAsync(ContentCreateModel createModel, int userId); Task> UpdateAsync(IContent content, ContentUpdateModel updateMode, int userId);