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,7 +1,7 @@
using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
using Microsoft.EntityFrameworkCore;
namespace EnvelopeGenerator.Infrastructure.Repositories
{
@@ -10,5 +10,20 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
public ReceiverRepository(EGDbContext dbContext) : base(dbContext)
{
}
protected IQueryable<Receiver> ReadBy(string? emailAddress = null, string? signature = null)
{
IQueryable<Receiver> query = _dbSet.AsNoTracking();
if(emailAddress is not null)
query = query.Where(r => r.EmailAddress == emailAddress);
if(signature is not null)
query = query.Where(r => r.Signature == signature);
return query;
}
public async Task<Receiver?> ReadByAsync(string? emailAddress = null, string? signature = null) => await ReadBy(emailAddress, signature).FirstOrDefaultAsync();
}
}