Developer 02 6338b81571 Refaktorisierung: Absicherung von DB-Operationen und Verbesserung der Geschäftslogik
- Implementierung von LINQ-Abfragen innerhalb der Core-Bibliothek zur Minderung von SQL-Injection-Anfälligkeiten für DB-Operationen von Umschlägen und Empfängern.
- Aktualisierung der Geschäftslogik in der Service-Schicht für verbessertes Transaktionshandling.
- Erweiterung der ServiceMessage um eine neue Flag-Funktion zum Verfolgen von Cybersecurity- und Datenintegritätsproblemen.
- Hinzufügen spezifischer Benutzerverhaltensflags zur besseren Erkennung und Behandlung potenzieller Datenverletzungen.
2024-04-24 13:45:03 +02:00

59 lines
2.4 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.EnvelopeReceivers);
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 withEnvelopeReceivers = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false)
{
var query = _dbSet.Where(e => e.Uuid == uuid);
if (signature is not null)
query = query.Where(e => e.EnvelopeReceivers != null && e.EnvelopeReceivers.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 || withEnvelopeReceivers)
query = query.Include(e => e.EnvelopeReceivers!).ThenInclude(er => er.Receiver);
if (withAll || withUser)
query = query.Include(e => e.User!);
if (withAll || withHistory)
query = query.Include(e => e.History);
return await query.FirstOrDefaultAsync();
}
}
}