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.
16 lines
552 B
C#
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");
|
|
}
|
|
} |