Developer 02 2c17d440c0 Integration von RemoveIfControllerConvention zur bedingten Ausschließung von Test-Controllern
Implementierung von RemoveIfControllerConvention in der Startup-Klasse, um Controller, die mit "Test" beginnen, basierend auf einem Konfigurationsflag auszuschließen, was die Flexibilität der Dienstregistrierung erhöht.
2024-04-09 13:52:38 +02:00

49 lines
2.0 KiB
C#

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<TestEnvelopeController, IEnvelopeService, IEnvelopeRepository, EnvelopeDto, Envelope, int>
{
public TestEnvelopeController(ILogger<TestEnvelopeController> logger, IEnvelopeService service) : base(logger, service)
{
}
[NonAction]
public override Task<IActionResult> GetAll()
{
return base.GetAll();
}
[HttpGet]
public virtual async Task<IActionResult> 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);
}
}
}