chore: init project
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using InboxIntel.Application.Abstractions;
|
||||
using InboxIntel.Application.DTOs;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace InboxIntel.Api.Controllers;
|
||||
|
||||
public class CleanupController : ApiControllerBase
|
||||
{
|
||||
private readonly ICleanupService _cleanup;
|
||||
public CleanupController(ICleanupService cleanup) => _cleanup = cleanup;
|
||||
|
||||
/// <summary>Preview which emails a cleanup action would affect. Always call before execute.</summary>
|
||||
[HttpPost("preview")]
|
||||
public async Task<IActionResult> Preview([FromBody] CleanupRequestDto request, CancellationToken ct)
|
||||
=> Ok(await _cleanup.PreviewAsync(UserId, request, ct));
|
||||
|
||||
/// <summary>Execute a cleanup action. Destructive actions require Confirmed = true.</summary>
|
||||
[HttpPost("execute")]
|
||||
public async Task<IActionResult> Execute([FromBody] CleanupRequestDto request, CancellationToken ct)
|
||||
{
|
||||
var result = await _cleanup.ExecuteAsync(UserId, request, ct);
|
||||
return result.Succeeded ? Ok(result.Value) : BadRequest(new { error = result.Error });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user