Add async get method to content editing service
This commit is contained in:
@@ -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<IActionResult> 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();
|
||||
|
||||
@@ -29,6 +29,12 @@ internal sealed class ContentEditingService
|
||||
_scopeProvider = scopeProvider;
|
||||
}
|
||||
|
||||
public async Task<IContent?> GetAsync(Guid id)
|
||||
{
|
||||
IContent? content = ContentService.GetById(id);
|
||||
return await Task.FromResult(content);
|
||||
}
|
||||
|
||||
public async Task<Attempt<IContent?, ContentEditingOperationStatus>> CreateAsync(ContentCreateModel createModel, int userId)
|
||||
{
|
||||
Attempt<IContent?, ContentEditingOperationStatus> result = await MapCreate(createModel);
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace Umbraco.Cms.Core.Services;
|
||||
|
||||
public interface IContentEditingService
|
||||
{
|
||||
Task<IContent?> GetAsync(Guid id);
|
||||
|
||||
Task<Attempt<IContent?, ContentEditingOperationStatus>> CreateAsync(ContentCreateModel createModel, int userId);
|
||||
|
||||
Task<Attempt<IContent, ContentEditingOperationStatus>> UpdateAsync(IContent content, ContentUpdateModel updateMode, int userId);
|
||||
|
||||
Reference in New Issue
Block a user