Developer 02 6f59906a7e - SQL-SELECT-Anweisungen in Dokumenten aktualisiert, um alle Spalten abzurufen.
- Prioritätsbehandlung für document_path_dmz in EnvelopeService.LoadEnvelopes hinzugefügt.
- CRUD-Operationen in EnvlopeDocument und ConfigurationFile Services/Repositories unter Verwendung von WebCoreModules implementiert.
- Verschiedene Dateimethoden in [spezifischen Orten oder Klassen, falls zutreffend] auf async umgestellt.
2024-03-14 12:46:38 +01:00

74 lines
2.5 KiB
C#

using Microsoft.AspNetCore.Mvc;
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Web.Services;
using static EnvelopeGenerator.Common.Constants;
using EnvelopeGenerator.Application.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class DocumentController : BaseController
{
private readonly EnvelopeService envelopeService;
private readonly ActionService? actionService;
private readonly IEnvelopeDocumentService _envDocService;
public DocumentController(DatabaseService database, LoggingService logging, EnvelopeService envelope, IEnvelopeDocumentService envDocService) : base(database, logging)
{
envelopeService = envelope;
actionService = database.Services?.actionService;
_envDocService = envDocService;
}
[HttpGet]
[Route("api/document/{envelopeKey}")]
public async Task<IActionResult> Get([FromRoute] string envelopeKey, [FromQuery] int index)
{
try
{
logger.Info("DocumentController/Get");
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeResponse response = await envelopeService.LoadEnvelope(envelopeKey);
// Load document info
var Request = ControllerContext.HttpContext.Request;
var document = await envelopeService.GetDocument(Request, envelopeKey);
// Load the document from disk
var bytes = await envelopeService.GetDocumentContents(document);
// Return the document as bytes
return File(bytes, "application/octet-stream");
}
catch (Exception e)
{
return ErrorResponse(e);
}
}
[HttpPost]
[Route("api/document/{envelopeKey}")]
public async Task<IActionResult> Open(string envelopeKey)
{
try
{
logger.Info("DocumentController/Open");
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeResponse response = await envelopeService.LoadEnvelope(envelopeKey);
actionService.OpenEnvelope(response.Envelope, response.Receiver);
return Ok(new object());
}
catch (Exception e)
{
return ErrorResponse(e);
}
}
}
}