refactor: Aktualisierung der Anwendungs- und Infrastrukturebenen, so dass die Infrastruktur von der Anwendung abhängig ist.

- Repository-Schnittstellen wurden in die Anwendungsschicht verschoben.
 - Erweiterungsmethoden für die Injektion von Repository-Abhängigkeiten wurden in die Infrastruktur verschoben.
This commit is contained in:
Developer 02
2025-02-12 19:31:13 +01:00
parent a5a8a9e416
commit 4615205aa5
119 changed files with 1112 additions and 1153 deletions

View File

@@ -1,37 +1,36 @@
using DigitalData.Core.Infrastructure;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
using EnvelopeGenerator.Application.Contracts.Repositories;
using Microsoft.EntityFrameworkCore;
namespace EnvelopeGenerator.Infrastructure.Repositories
namespace EnvelopeGenerator.Infrastructure.Repositories;
public class ReceiverRepository : CRUDRepository<Receiver, int, EGDbContext>, IReceiverRepository
{
public class ReceiverRepository : CRUDRepository<Receiver, int, EGDbContext>, IReceiverRepository
public ReceiverRepository(EGDbContext dbContext) : base(dbContext, dbContext.Receivers)
{
public ReceiverRepository(EGDbContext dbContext) : base(dbContext, dbContext.Receivers)
{
}
protected IQueryable<Receiver> ReadBy(string? emailAddress = null, string? signature = null, bool withLastUsedName = true)
{
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);
// envelope receivers are ignored (with '[JsonIgnore]' attribute). The reson to add them is to get the las used receiver name
if (withLastUsedName)
{
query = query.Include(r => r.EnvelopeReceivers!.OrderByDescending(er => er.EnvelopeId).Take(1));
}
return query;
}
public async Task<Receiver?> ReadByAsync(string? emailAddress = null, string? signature = null) => await ReadBy(emailAddress, signature).FirstOrDefaultAsync();
public async override Task<IEnumerable<Receiver>> ReadAllAsync() => await ReadBy().ToListAsync();
}
protected IQueryable<Receiver> ReadBy(string? emailAddress = null, string? signature = null, bool withLastUsedName = true)
{
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);
// envelope receivers are ignored (with '[JsonIgnore]' attribute). The reson to add them is to get the las used receiver name
if (withLastUsedName)
{
query = query.Include(r => r.EnvelopeReceivers!.OrderByDescending(er => er.EnvelopeId).Take(1));
}
return query;
}
public async Task<Receiver?> ReadByAsync(string? emailAddress = null, string? signature = null) => await ReadBy(emailAddress, signature).FirstOrDefaultAsync();
public async override Task<IEnumerable<Receiver>> ReadAllAsync() => await ReadBy().ToListAsync();
}