Delete.cs 911 B

12345678910111213141516171819202122232425262728293031
  1. using System.Security.Claims;
  2. using MediatR;
  3. using Web.Api.Common;
  4. using Web.Api.Extensions;
  5. namespace Web.Api.Endpoints.Note;
  6. /// <summary>받은 쪽지 삭제 (soft delete — IsDeletedByReceiver)</summary>
  7. internal sealed class Delete : IEndpoint
  8. {
  9. public void MapEndpoint(IEndpointRouteBuilder app)
  10. {
  11. app.MapDelete("api/note/{id:int}", async (
  12. int id,
  13. ClaimsPrincipal user,
  14. ISender sender,
  15. CancellationToken ct
  16. ) => {
  17. var memberID = user.GetRequiredMemberID();
  18. var command = new Application.Features.Api.Note.DeleteNote.Command(id, memberID);
  19. var result = await sender.Send(command, ct);
  20. return result.Match(
  21. () => ApiResponse.Ok(true),
  22. CustomResults.Problem
  23. );
  24. })
  25. .WithTags("Note")
  26. .RequireAuthorization();
  27. }
  28. }