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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user