using EnvelopeGenerator.Application.Contracts; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Application.Services; using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Infrastructure.Contracts; using Microsoft.AspNetCore.Mvc; namespace EnvelopeGenerator.Web.Controllers.Test { public class TestEnvelopeController : TestControllerBase { public TestEnvelopeController(ILogger logger, IEnvelopeService service) : base(logger, service) { } [NonAction] public override Task GetAll() { return base.GetAll(); } [HttpGet] public virtual async Task GetAll([FromQuery] string? envelopeKey = default, [FromQuery] bool withDocuments = false, [FromQuery] bool withReceivers = false, [FromQuery] bool withHistory = false, [FromQuery] bool withDocumentReceiverElement = false, [FromQuery] bool withAll = true) { if(envelopeKey is not null) { var decoded = envelopeKey.DecodeEnvelopeReceiverId(); var envlopeServiceResult = await _service.ReadByUuidAsync( uuid: decoded.EnvelopeUuid, signature: decoded.ReceiverSignature, withDocuments: withDocuments, withReceivers: withReceivers, withHistory: withHistory, withDocumentReceiverElement:withDocumentReceiverElement, withAll:withAll); if (envlopeServiceResult.IsSuccess) { return Ok(envlopeServiceResult.Data); } return NotFound(); } var result = await _service.ReadAllWithAsync(documents: withDocuments, receivers: withReceivers, history: withHistory); if (result.IsSuccess) { return Ok(result); } return NotFound(result); } } }