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

56 lines
2.2 KiB
C#

using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
using Microsoft.EntityFrameworkCore;
namespace EnvelopeGenerator.Infrastructure.Repositories
{
public class EnvelopeRepository : CRUDRepository<Envelope, int, EGDbContext>, IEnvelopeRepository
{
public EnvelopeRepository(EGDbContext dbContext) : base(dbContext)
{
}
public async Task<IEnumerable<Envelope>> ReadAllWithAsync(bool documents = false, bool receivers = false, bool history = false, bool documentReceiverElement = false)
{
var query = _dbSet.AsQueryable();
if (documents)
if (documentReceiverElement)
query = query.Include(e => e.Documents!).ThenInclude(d => d.Elements);
else
query = query.Include(e => e.Documents);
if (receivers)
query = query.Include(e => e.Receivers);
if (history)
query = query.Include(e => e.History);
return await query.ToListAsync();
}
public async Task<Envelope?> ReadByUuidAsync(string uuid, string? signature = null, bool withDocuments = false, bool withReceivers = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withAll = false)
{
var query = _dbSet.Where(e => e.Uuid == uuid);
if (signature is not null)
query = query.Where(e => e.Receivers != null && e.Receivers.Any(er => er.Receiver != null && er.Receiver.Signature == signature));
if (withAll || withDocuments)
if (withAll || withDocumentReceiverElement)
query = query.Include(e => e.Documents!).ThenInclude(d => d.Elements);
else
query = query.Include(e => e.Documents);
if (withAll || withReceivers)
query = query.Include(e => e.Receivers!).ThenInclude(er => er.Receiver);
if (withAll || withHistory)
query = query.Include(e => e.History);
return await query.FirstOrDefaultAsync();
}
}
}