using Microsoft.AspNetCore.Mvc; using EnvelopeGenerator.CommonServices; using EnvelopeGenerator.Web.Services; using Microsoft.AspNetCore.Authorization; using EnvelopeGenerator.Application.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 logger) : base(database, logger) { envelopeService = envelope; actionService = database.Services?.actionService; } [Obsolete("Use MediatR")] [NonAction] public async Task Get([FromRoute] string envelopeKey, [FromQuery] int index) { // 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"); } }