Added [Obsolete("Use MediatR")] attribute to several methods
across `DocumentController`, `HomeController`,
`TestConfigController`, `TestDocumentReceiverElementController`,
and `TestEnvelopeController` to indicate they should no longer
be used.
Refactored constructors in `TestConfigController` and
`TestEnvelopeController` to remove unnecessary empty blocks.
Improved formatting and structure of the `GetAll` method in
`TestEnvelopeController` for better clarity while maintaining
functionality.
Updated `Program.cs` to suppress warnings about obsolete
types/members during service registrations, indicating a
transition to newer implementations.
81 lines
2.8 KiB
C#
81 lines
2.8 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using EnvelopeGenerator.CommonServices;
|
|
using EnvelopeGenerator.Web.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using EnvelopeGenerator.Extensions;
|
|
using EnvelopeGenerator.Application.Contracts.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")]
|
|
private readonly IEnvelopeDocumentService _envDocService;
|
|
|
|
[Obsolete("Use MediatR")]
|
|
public DocumentController(DatabaseService database, EnvelopeOldService envelope, IEnvelopeDocumentService envDocService, ILogger<DocumentController> logger) : base(database, logger)
|
|
{
|
|
envelopeService = envelope;
|
|
actionService = database.Services?.actionService;
|
|
_envDocService = envDocService;
|
|
}
|
|
|
|
[Obsolete("Use MediatR")]
|
|
[NonAction]
|
|
public async Task<IActionResult> Get([FromRoute] string envelopeKey, [FromQuery] int index)
|
|
{
|
|
try
|
|
{
|
|
// Validate Envelope Key and load envelope
|
|
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
|
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");
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
_logger.LogError(ex, "{Message}", ex.Message);
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
}
|
|
}
|
|
|
|
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
|
[HttpPost("{envelopeKey}")]
|
|
[Obsolete("Use MediatR")]
|
|
public async Task<IActionResult> Open(string envelopeKey)
|
|
{
|
|
try
|
|
{
|
|
var authSignature = this.GetAuthReceiverSignature();
|
|
|
|
if (authSignature != envelopeKey.GetReceiverSignature())
|
|
return Forbid();
|
|
|
|
// Validate Envelope Key and load envelope
|
|
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
|
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
|
|
|
|
actionService?.OpenEnvelope(response.Envelope, response.Receiver);
|
|
|
|
return Ok(new object());
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
_logger.LogError(ex, "{Message}", ex.Message);
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
}
|
|
}
|
|
} |