Refactor EnvelopeReceiverExecutor and Repository methods

- Updated `EnvelopeReceiverExecutor` to inherit from `SQLExecutor` and added `_erRepository` for enhanced data access.
- Introduced `AddEnvelopeReceiverAsync` method for retrieving envelope receivers.
- Modified `ReadById` in `EnvelopeReceiverRepository` to support flexible querying with new parameters.
- Updated `ReadByIdAsync` to align with changes in `ReadById`.
This commit is contained in:
Developer 02
2025-05-06 10:33:17 +02:00
parent 749366fff5
commit 82fc7fa762
3 changed files with 42 additions and 5 deletions

View File

@@ -48,9 +48,19 @@ public class EnvelopeReceiverRepository : CRUDRepository<EnvelopeReceiver, (int
public async Task<int> CountAsync(string uuid, string signature) => await ReadWhere(uuid: uuid, signature: signature).CountAsync();
private IQueryable<EnvelopeReceiver> ReadById(int envelopeId, int receiverId, bool readOnly = true)
private IQueryable<EnvelopeReceiver> ReadById(int envelopeId, int receiverId, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true)
{
var query = readOnly ? _dbSet.AsNoTracking() : _dbSet;
if (withEnvelope)
query = query
.Include(er => er.Envelope).ThenInclude(e => e!.Documents!).ThenInclude(d => d.Elements!.Where(e => e.Receiver!.Id == receiverId))
.Include(er => er.Envelope).ThenInclude(e => e!.History)
.Include(er => er.Envelope).ThenInclude(e => e!.User);
if (withReceiver)
query = query.Include(er => er.Receiver);
return query.Where(er => er.EnvelopeId == envelopeId && er.ReceiverId == receiverId);
}