Files
EnvelopeGenerator/EnvelopeGenerator.ServiceHost/Controllers/DocResultController.cs
TekH a72cbab195 Add GET endpoint to return envelope PDF by UUID
Added a new HTTP GET action to DocResultController that accepts a ReadSingleEnvelopeDocResultQuery via query string. The endpoint uses MediatR to retrieve the PDF document and returns it as a file response with the envelope's UUID in the filename and the correct content type.
2026-04-09 14:05:54 +02:00

16 lines
552 B
C#

using EnvelopeGenerator.Application.Envelopes.Queries;
using MediatR;
using Microsoft.AspNetCore.Mvc;
namespace EnvelopeGenerator.ServiceHost.Controllers;
[Route("api/[controller]")]
[ApiController]
public class DocResultController(IMediator mediator) : ControllerBase
{
[HttpGet]
public async Task<IActionResult> GetAsync([FromQuery] ReadSingleEnvelopeDocResultQuery query, CancellationToken cancel = default)
{
return File(await mediator.Send(query, cancel), "application/pdf", $"envelope_{query.Envelope.Uuid}.pdf");
}
}