2023-05-09 08:38:07 +02:00
|
|
|
|
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;
|
|
|
|
|
|
|
2023-05-09 08:38:07 +02:00
|
|
|
|
[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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-09 08:38:07 +02:00
|
|
|
|
[MapToApiVersion("1.0")]
|
2023-04-04 13:20:29 +02:00
|
|
|
|
[HttpGet("{id:guid}/notifications")]
|
2023-03-29 10:48:30 +02:00
|
|
|
|
[ProducesResponseType(typeof(IEnumerable<DocumentNotificationResponseModel>), StatusCodes.Status200OK)]
|
2023-08-04 10:51:20 +02:00
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
|
2023-04-04 13:20:29 +02:00
|
|
|
|
public async Task<IActionResult> Notifications(Guid id)
|
2023-03-29 10:48:30 +02:00
|
|
|
|
{
|
2023-04-04 13:20:29 +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();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|