- HomeController und ShowEnvelopeView aktualisiert. - Endlosschleifenproblem zwischen Envelope und EnvelopeReceiver gelöst. - Anpassungen an Envelope, EnvelopeDTO, EnvelopeRepository und EnvelopeService vorgenommen.
50 lines
1.8 KiB
C#
50 lines
1.8 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 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 (history)
|
|
query = query.Include(e => e.History);
|
|
|
|
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.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 || withUser)
|
|
query = query.Include(e => e.User!);
|
|
|
|
if (withAll || withHistory)
|
|
query = query.Include(e => e.History);
|
|
|
|
return await query.FirstOrDefaultAsync();
|
|
}
|
|
}
|
|
} |