Files
Umbraco-CMS/src/Umbraco.Cms.Api.Management/Controllers/Document/NotificationsController.cs

35 lines
1.4 KiB
C#
Raw Normal View History

using Asp.Versioning;
using Microsoft.AspNetCore.Http;
2023-03-29 10:48:30 +02:00
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Api.Management.Factories;
using Umbraco.Cms.Api.Management.ViewModels.Document;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;
namespace Umbraco.Cms.Api.Management.Controllers.Document;
[ApiVersion("1.0")]
2023-03-29 10:48:30 +02:00
public class NotificationsController : DocumentControllerBase
{
private readonly IContentEditingService _contentEditingService;
private readonly IDocumentNotificationPresentationFactory _documentNotificationPresentationFactory;
public NotificationsController(IContentEditingService contentEditingService, IDocumentNotificationPresentationFactory documentNotificationPresentationFactory)
{
_contentEditingService = contentEditingService;
_documentNotificationPresentationFactory = documentNotificationPresentationFactory;
}
[MapToApiVersion("1.0")]
[HttpGet("{id:guid}/notifications")]
2023-03-29 10:48:30 +02:00
[ProducesResponseType(typeof(IEnumerable<DocumentNotificationResponseModel>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
public async Task<IActionResult> Notifications(Guid id)
2023-03-29 10:48:30 +02:00
{
IContent? content = await _contentEditingService.GetAsync(id);
2023-03-29 10:48:30 +02:00
return content != null
? Ok(await _documentNotificationPresentationFactory.CreateNotificationModelsAsync(content))
: DocumentNotFound();
}
}