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:
@@ -1,65 +1,64 @@
|
||||
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 EnvelopeRepository : CRUDRepository<Envelope, int, EGDbContext>, IEnvelopeRepository
|
||||
{
|
||||
public class EnvelopeRepository : CRUDRepository<Envelope, int, EGDbContext>, IEnvelopeRepository
|
||||
public EnvelopeRepository(EGDbContext dbContext) : base(dbContext, dbContext.Envelopes)
|
||||
{
|
||||
public EnvelopeRepository(EGDbContext dbContext) : base(dbContext, dbContext.Envelopes)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Envelope>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false)
|
||||
{
|
||||
var query = _dbSet.AsNoTracking();
|
||||
public async Task<IEnumerable<Envelope>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false)
|
||||
{
|
||||
var query = _dbSet.AsNoTracking();
|
||||
|
||||
if (documents)
|
||||
if (documentReceiverElement)
|
||||
query = query.Include(e => e.Documents!).ThenInclude(d => d.Elements);
|
||||
else
|
||||
query = query.Include(e => e.Documents);
|
||||
if (documents)
|
||||
if (documentReceiverElement)
|
||||
query = query.Include(e => e.Documents!).ThenInclude(d => d.Elements);
|
||||
else
|
||||
query = query.Include(e => e.Documents);
|
||||
|
||||
if (history)
|
||||
query = query.Include(e => e.History);
|
||||
if (history)
|
||||
query = query.Include(e => e.History);
|
||||
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Envelope?> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false)
|
||||
{
|
||||
var query = _dbSet.AsNoTracking().Where(e => e.Uuid == uuid);
|
||||
public async Task<Envelope?> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false)
|
||||
{
|
||||
var query = _dbSet.AsNoTracking().Where(e => e.Uuid == uuid);
|
||||
|
||||
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 || withDocuments)
|
||||
if (withAll || withDocumentReceiverElement)
|
||||
query = query.Include(e => e.Documents!).ThenInclude(d => d.Elements);
|
||||
else
|
||||
query = query.Include(e => e.Documents);
|
||||
|
||||
if (withAll || withUser)
|
||||
query = query.Include(e => e.User!);
|
||||
if (withAll || withUser)
|
||||
query = query.Include(e => e.User!);
|
||||
|
||||
if (withAll || withHistory)
|
||||
query = query.Include(e => e.History);
|
||||
if (withAll || withHistory)
|
||||
query = query.Include(e => e.History);
|
||||
|
||||
return await query.FirstOrDefaultAsync();
|
||||
}
|
||||
return await query.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Envelope>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses)
|
||||
{
|
||||
var query = _dbSet.AsNoTracking().Where(e => e.UserId == userId);
|
||||
public async Task<IEnumerable<Envelope>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses)
|
||||
{
|
||||
var query = _dbSet.AsNoTracking().Where(e => e.UserId == userId);
|
||||
|
||||
if (min_status is not null)
|
||||
query = query.Where(e => e.Status >= min_status);
|
||||
if (min_status is not null)
|
||||
query = query.Where(e => e.Status >= min_status);
|
||||
|
||||
if (max_status is not null)
|
||||
query = query.Where(e => e.Status <= max_status);
|
||||
if (max_status is not null)
|
||||
query = query.Where(e => e.Status <= max_status);
|
||||
|
||||
foreach (var ignore_status in ignore_statuses)
|
||||
query = query.Where(e => e.Status != ignore_status);
|
||||
foreach (var ignore_status in ignore_statuses)
|
||||
query = query.Where(e => e.Status != ignore_status);
|
||||
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user