using DigitalData.Core.API; 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 { public class TestEnvelopeController : CRUDControllerBase { 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 = true, [FromQuery] bool withReceivers = true, [FromQuery] bool withHistory = 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); 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); } } }