46 lines
1.9 KiB
C#
46 lines
1.9 KiB
C#
using EnvelopeGenerator.Application;
|
|
using EnvelopeGenerator.Application.Contracts;
|
|
using EnvelopeGenerator.Application.DTOs;
|
|
using EnvelopeGenerator.Domain.Entities;
|
|
using EnvelopeGenerator.Infrastructure.Contracts;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace EnvelopeGenerator.Web.Controllers.Test
|
|
{
|
|
public class TestEnvelopeController : TestControllerBase<IEnvelopeService, IEnvelopeRepository, EnvelopeDto, Envelope, int>
|
|
{
|
|
public TestEnvelopeController(ILogger<TestEnvelopeController> logger, IEnvelopeService service) : base(logger, service)
|
|
{
|
|
}
|
|
|
|
[NonAction]
|
|
public override Task<IActionResult> GetAll() => base.GetAll();
|
|
|
|
[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)
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
} |