41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using EnvelopeGenerator.CommonServices;
|
|
using EnvelopeGenerator.Web.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using EnvelopeGenerator.Extensions;
|
|
using EnvelopeGenerator.Application.Interfaces.Services;
|
|
using static EnvelopeGenerator.Domain.Constants;
|
|
using EnvelopeGenerator.Domain.Entities;
|
|
|
|
namespace EnvelopeGenerator.Web.Controllers;
|
|
|
|
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
|
[Route("api/[controller]")]
|
|
public class DocumentController : BaseController
|
|
{
|
|
private readonly EnvelopeOldService envelopeService;
|
|
private readonly ActionService? actionService;
|
|
|
|
[Obsolete("Use MediatR")]
|
|
public DocumentController(DatabaseService database, EnvelopeOldService envelope, ILogger<DocumentController> logger) : base(database, logger)
|
|
{
|
|
envelopeService = envelope;
|
|
actionService = database.Services?.actionService;
|
|
}
|
|
|
|
[Obsolete("Use MediatR")]
|
|
[NonAction]
|
|
public async Task<IActionResult> Get([FromRoute] string envelopeKey, [FromQuery] int index)
|
|
{
|
|
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
|
|
|
|
// Load document info
|
|
var document = await envelopeService.GetDocument(index, envelopeKey);
|
|
|
|
// Load the document from disk
|
|
var bytes = await envelopeService.GetDocumentContents(document);
|
|
|
|
// Return the document as bytes
|
|
return File(bytes, "application/octet-stream");
|
|
}
|
|
} |