Compare commits
1 Commits
refactor/a
...
0d78e9b8f5
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d78e9b8f5 |
@@ -1,56 +1,32 @@
|
|||||||
using EnvelopeGenerator.Domain.Entities;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using EnvelopeGenerator.Application.Common.Dto;
|
|
||||||
using EnvelopeGenerator.Application.Common.Extensions;
|
using EnvelopeGenerator.Application.Common.Extensions;
|
||||||
using EnvelopeGenerator.Application.Common.Interfaces.Services;
|
using MediatR;
|
||||||
|
using EnvelopeGenerator.Application.Envelopes.Queries;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers.Test;
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||||
|
|
||||||
[Obsolete("Use MediatR")]
|
[Obsolete("Use MediatR")]
|
||||||
public class TestEnvelopeController : TestControllerBase<IEnvelopeService, EnvelopeDto, Envelope, int>
|
public class TestEnvelopeController : ControllerBase
|
||||||
{
|
{
|
||||||
public TestEnvelopeController(ILogger<TestEnvelopeController> logger, IEnvelopeService service) : base(logger, service)
|
private readonly IMediator _mediator;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[NonAction]
|
/// <summary>
|
||||||
public override Task<IActionResult> GetAll() => base.GetAll();
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mediator"></param>
|
||||||
|
public TestEnvelopeController(IMediator mediator)
|
||||||
|
{
|
||||||
|
_mediator = mediator;
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> GetAll([FromQuery] string? envelopeKey = default, [FromQuery] bool withDocuments = false, [FromQuery] bool withHistory = false, [FromQuery] bool withDocumentReceiverElement = false, [FromQuery] bool withUser = false, [FromQuery] bool withAll = true)
|
public async Task<IActionResult> GetAll([FromQuery] ReadEnvelopeQuery query, CancellationToken cancel) => Ok(await _mediator.Send(query, cancel));
|
||||||
{
|
|
||||||
if (envelopeKey is not null)
|
|
||||||
{
|
|
||||||
(var uuid, var signature) = envelopeKey.DecodeEnvelopeReceiverId();
|
|
||||||
if (uuid is null)
|
|
||||||
return BadRequest("UUID is null");
|
|
||||||
var envlopeServiceResult = await _service.ReadByUuidAsync(
|
|
||||||
uuid: uuid,
|
|
||||||
withDocuments: withDocuments, withHistory: withHistory, withDocumentReceiverElement: withDocumentReceiverElement, withUser: withUser, withAll: withAll);
|
|
||||||
|
|
||||||
if (envlopeServiceResult.IsSuccess)
|
|
||||||
{
|
|
||||||
return Ok(envlopeServiceResult.Data);
|
|
||||||
}
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = await _service.ReadAllWithAsync(documents: withDocuments, history: withHistory);
|
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
return NotFound(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("decode")]
|
[HttpGet("decode")]
|
||||||
public IActionResult DecodeEnvelopeReceiverId(string envelopeReceiverId, int type = 0)
|
public IActionResult DecodeEnvelopeReceiverId(string envelopeReceiverId, int type = 0) => type switch
|
||||||
{
|
|
||||||
return type switch
|
|
||||||
{
|
{
|
||||||
1 => Ok(envelopeReceiverId.GetEnvelopeUuid()),
|
1 => Ok(envelopeReceiverId.GetEnvelopeUuid()),
|
||||||
2 => Ok(envelopeReceiverId.GetReceiverSignature()),
|
2 => Ok(envelopeReceiverId.GetReceiverSignature()),
|
||||||
_ => Ok(envelopeReceiverId.DecodeEnvelopeReceiverId()),
|
_ => Ok(envelopeReceiverId.DecodeEnvelopeReceiverId()),
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user