feat: Filterung nach emailAddress und signature im Receiver-Repository, -Service und -Controller hinzugefügt

- `ReadBy`-Methode im Receiver-Repository implementiert, um nach `emailAddress` und `signature` zu filtern.
- `ReadByAsync`-Methode im Receiver-Service hinzugefügt, um Receiver-Daten abzurufen und zuzuordnen.
- Controller-`Get`-Endpunkt aktualisiert, um optionale `emailAddress` und `signature` Query-Parameter für die Filterung zu unterstützen.
- Fehlerbehandlung mit Protokollierung für fehlgeschlagene Service-Operationen im Controller hinzugefügt.
This commit is contained in:
Developer 02
2024-08-21 15:05:18 +02:00
parent afedfdd596
commit b96c6c10f8
5 changed files with 53 additions and 1 deletions

View File

@@ -1,8 +1,10 @@
using DigitalData.Core.API;
using DigitalData.Core.DTO;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs.Receiver;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations.Schema;
namespace EnvelopeGenerator.GeneratorAPI.Controllers
{
@@ -13,5 +15,26 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
public ReceiverController(ILogger logger, IReceiverService service) : base(logger, service)
{
}
[NonAction]
public override Task<IActionResult> GetAll()
{
return base.GetAll();
}
[HttpGet]
public async Task<IActionResult> Get([FromQuery] string? emailAddress = null, [FromQuery] string? signature = null)
{
if (emailAddress is null && signature is null)
return await base.GetAll();
return await _service.ReadByAsync(emailAddress: emailAddress, signature: signature).ThenAsync(
Success: Ok,
Fail: IActionResult (msg,ntc) =>
{
_logger.LogNotice(ntc);
return StatusCode(StatusCodes.Status500InternalServerError);
});
}
}
}