2023-05-09 08:38:07 +02:00
|
|
|
|
using Asp.Versioning;
|
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
2023-03-16 08:25:15 +01:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using Umbraco.Cms.Core;
|
|
|
|
|
|
using Umbraco.Cms.Core.Models.TemporaryFile;
|
|
|
|
|
|
using Umbraco.Cms.Core.Services;
|
|
|
|
|
|
using Umbraco.Cms.Core.Services.OperationStatus;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Cms.Api.Management.Controllers.TemporaryFile;
|
|
|
|
|
|
|
2023-05-09 08:38:07 +02:00
|
|
|
|
[ApiVersion("1.0")]
|
2023-03-16 08:25:15 +01:00
|
|
|
|
public class DeleteTemporaryFileController : TemporaryFileControllerBase
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly ITemporaryFileService _temporaryFileService;
|
|
|
|
|
|
|
|
|
|
|
|
public DeleteTemporaryFileController(ITemporaryFileService temporaryFileService) => _temporaryFileService = temporaryFileService;
|
|
|
|
|
|
|
2023-04-04 13:20:29 +02:00
|
|
|
|
[HttpDelete($"{{{nameof(id)}}}")]
|
2023-03-16 08:25:15 +01:00
|
|
|
|
[MapToApiVersion("1.0")]
|
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
|
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2023-04-04 13:20:29 +02:00
|
|
|
|
public async Task<IActionResult> Delete(Guid id)
|
2023-03-16 08:25:15 +01:00
|
|
|
|
{
|
2023-04-04 13:20:29 +02:00
|
|
|
|
Attempt<TemporaryFileModel?, TemporaryFileOperationStatus> result = await _temporaryFileService.DeleteAsync(id);
|
2023-03-16 08:25:15 +01:00
|
|
|
|
|
|
|
|
|
|
return result.Success
|
|
|
|
|
|
? Ok()
|
|
|
|
|
|
: TemporaryFileStatusResult(result.Status);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|