Updated several C# controllers to use the new
`DigitalData.Core.Abstraction.Application.DTO` namespace
and removed references to `DigitalData.Core.DTO`. Added
`[Obsolete("Use MediatR")]` attributes to indicate a shift
towards MediatR for request handling. Improved error
handling and code organization in key methods. Updated
Razor view files to reflect namespace changes for
consistency across the application.
66 lines
2.6 KiB
C#
66 lines
2.6 KiB
C#
using DigitalData.Core.API;
|
|
using EnvelopeGenerator.Extensions;
|
|
using EnvelopeGenerator.Domain.Entities;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
|
using EnvelopeGenerator.Application.Contracts.Services;
|
|
using DigitalData.Core.Abstraction.Application.DTO;
|
|
|
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
|
|
|
[Obsolete("Use MediatR")]
|
|
public class TestEnvelopeReceiverController : ReadControllerBase<IEnvelopeReceiverService, EnvelopeReceiverDto, EnvelopeReceiver, (int Envelope, int Receiver)>
|
|
{
|
|
public TestEnvelopeReceiverController(ILogger<TestEnvelopeReceiverController> logger, IEnvelopeReceiverService service) : base(logger, service)
|
|
{
|
|
}
|
|
|
|
[HttpGet("verify-access-code/{envelope_receiver_id}")]
|
|
public async Task<IActionResult> VerifyAccessCode([FromRoute] string envelope_receiver_id, [FromQuery] string access_code)
|
|
{
|
|
var verification = await _service.VerifyAccessCodeAsync(envelopeReceiverId:envelope_receiver_id, accessCode: access_code);
|
|
|
|
if (verification.IsSuccess)
|
|
return Ok(verification);
|
|
else if (verification.HasFlag(Flag.SecurityBreach))
|
|
return Forbid();
|
|
else if (verification.HasFlag(Flag.SecurityBreachOrDataIntegrity))
|
|
return Conflict();
|
|
else
|
|
return this.InnerServiceError(verification);
|
|
}
|
|
|
|
[HttpGet("e-r-id/{envelope_receiver_id}")]
|
|
public async Task<IActionResult> GetByEnvelopeReceiverId([FromRoute] string envelope_receiver_id)
|
|
{
|
|
var er_result = await _service.ReadByEnvelopeReceiverIdAsync(envelopeReceiverId: envelope_receiver_id);
|
|
if (er_result.IsSuccess)
|
|
return Ok(er_result);
|
|
else
|
|
return this.InnerServiceError(er_result);
|
|
}
|
|
|
|
[HttpGet("decode")]
|
|
public IActionResult DecodeEnvelopeReceiverId(string envelopeReceiverId, bool isReadOnly = false)
|
|
{
|
|
if (isReadOnly)
|
|
{
|
|
var readOnlyId = envelopeReceiverId.DecodeEnvelopeReceiverReadOnlyId();
|
|
return Ok(new { readOnlyId });
|
|
}
|
|
else
|
|
{
|
|
var (EnvelopeUuid, ReceiverSignature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
|
|
return Ok(new { uuid = EnvelopeUuid, signature = ReceiverSignature });
|
|
}
|
|
}
|
|
|
|
[HttpGet("encode")]
|
|
public IActionResult EncodeEnvelopeReceiverId(string? uuid = null, string? signature = null, long? readOnlyId = null)
|
|
{
|
|
if(readOnlyId is long readOnlyId_long)
|
|
return Ok(readOnlyId_long.EncodeEnvelopeReceiverId());
|
|
else
|
|
return Ok((uuid ?? string.Empty, signature ?? string.Empty).EncodeEnvelopeReceiverId());
|
|
}
|
|
} |