2023-02-20 11:08:22 +01:00
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using Umbraco.Cms.Core;
|
|
|
|
|
|
using Umbraco.Cms.Core.Models;
|
|
|
|
|
|
using Umbraco.Cms.Core.Security;
|
|
|
|
|
|
using Umbraco.Cms.Core.Services;
|
|
|
|
|
|
using Umbraco.Cms.Core.Services.OperationStatus;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Cms.Api.Management.Controllers.Document;
|
|
|
|
|
|
|
|
|
|
|
|
public class MoveToRecycleBinDocumentController : DocumentControllerBase
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IContentEditingService _contentEditingService;
|
|
|
|
|
|
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
|
|
|
|
|
|
|
|
|
|
|
public MoveToRecycleBinDocumentController(IContentEditingService contentEditingService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor)
|
|
|
|
|
|
{
|
|
|
|
|
|
_contentEditingService = contentEditingService;
|
|
|
|
|
|
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-04 13:20:29 +02:00
|
|
|
|
[HttpDelete("{id:guid}")]
|
2023-02-20 11:08:22 +01:00
|
|
|
|
[MapToApiVersion("1.0")]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
2023-04-04 13:20:29 +02:00
|
|
|
|
public async Task<IActionResult> MoveToRecycleBin(Guid id)
|
2023-02-20 11:08:22 +01:00
|
|
|
|
{
|
2023-04-04 13:20:29 +02:00
|
|
|
|
Attempt<IContent?, ContentEditingOperationStatus> result = await _contentEditingService.MoveToRecycleBinAsync(id, CurrentUserKey(_backOfficeSecurityAccessor));
|
2023-02-20 11:08:22 +01:00
|
|
|
|
return result.Success
|
|
|
|
|
|
? Ok()
|
|
|
|
|
|
: ContentEditingOperationStatusResult(result.Status);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|