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.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using DigitalData.UserManager.Infrastructure.Repositories;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
||||
{
|
||||
@@ -10,5 +11,21 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
|
||||
public EnvelopeHistoryRepository(EGDbContext dbContext) : base(dbContext)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null)
|
||||
{
|
||||
var query = _dbSet.AsQueryable();
|
||||
|
||||
if (envelopeId is not null)
|
||||
query = query.Where(eh => eh.EnvelopeId == envelopeId);
|
||||
|
||||
if (userReference is not null)
|
||||
query = query.Where(eh => eh.UserReference == userReference);
|
||||
|
||||
if (status is not null)
|
||||
query = query.Where(eh => eh.Status == status);
|
||||
|
||||
return await query.CountAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
|
||||
query = query.Include(e => e.Documents);
|
||||
|
||||
if (receivers)
|
||||
query = query.Include(e => e.Receivers);
|
||||
query = query.Include(e => e.EnvelopeReceivers);
|
||||
|
||||
if (history)
|
||||
query = query.Include(e => e.History);
|
||||
@@ -31,12 +31,12 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
|
||||
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)
|
||||
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.Receivers != null && e.Receivers.Any(er => er.Receiver != null && er.Receiver.Signature == signature));
|
||||
query = query.Where(e => e.EnvelopeReceivers != null && e.EnvelopeReceivers.Any(er => er.Receiver != null && er.Receiver.Signature == signature));
|
||||
|
||||
if (withAll || withDocuments)
|
||||
if (withAll || withDocumentReceiverElement)
|
||||
@@ -44,8 +44,11 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
|
||||
else
|
||||
query = query.Include(e => e.Documents);
|
||||
|
||||
if (withAll || withReceivers)
|
||||
query = query.Include(e => e.Receivers!).ThenInclude(er => er.Receiver);
|
||||
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);
|
||||
|
||||
@@ -3,6 +3,7 @@ using DigitalData.UserManager.Infrastructure.Repositories;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
|
||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
||||
{
|
||||
@@ -12,14 +13,37 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<string?> ReadAccessCodeByEnvelopeUuid(string envelopeUuid)
|
||||
private IQueryable<EnvelopeReceiver> ReadWhere(string? uuid = null, string? signature = null, bool withEnvelope = false, bool withReceiver = false)
|
||||
{
|
||||
var accessCode = await _dbSet
|
||||
.Where(er => er.Envelope != null && er.Envelope.Uuid == envelopeUuid)
|
||||
var query = _dbSet.AsQueryable();
|
||||
|
||||
if(uuid is not null)
|
||||
query = query.Where(er => er.Envelope != null && er.Envelope.Uuid == uuid);
|
||||
|
||||
if (signature is not null)
|
||||
query = query.Where(er => er.Receiver != null && er.Receiver.Signature == signature);
|
||||
|
||||
if (withEnvelope)
|
||||
query = query.Include(er => er.Envelope);
|
||||
|
||||
if (withReceiver)
|
||||
query = query.Include(er => er.Receiver);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<EnvelopeReceiver>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false)
|
||||
=> await ReadWhere(uuid: uuid, withEnvelope: withEnvelope, withReceiver: withReceiver).ToListAsync();
|
||||
|
||||
public async Task<IEnumerable<EnvelopeReceiver>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true)
|
||||
=> await ReadWhere(signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver).ToListAsync();
|
||||
|
||||
public async Task<EnvelopeReceiver?> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true)
|
||||
=> await ReadWhere(uuid: uuid, signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver).FirstOrDefaultAsync();
|
||||
|
||||
public async Task<string?> ReadAccessCodeAsync(string uuid, string signature)
|
||||
=> await ReadWhere(uuid:uuid, signature:signature)
|
||||
.Select(er => er.AccessCode)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
return accessCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user