diff --git a/EnvelopeGenerator.Infrastructure/Contracts/IEnvelopeReceiverRepository.cs b/EnvelopeGenerator.Infrastructure/Contracts/IEnvelopeReceiverRepository.cs index 4aa2946c..ffd56528 100644 --- a/EnvelopeGenerator.Infrastructure/Contracts/IEnvelopeReceiverRepository.cs +++ b/EnvelopeGenerator.Infrastructure/Contracts/IEnvelopeReceiverRepository.cs @@ -5,19 +5,19 @@ namespace EnvelopeGenerator.Infrastructure.Contracts { public interface IEnvelopeReceiverRepository : ICRUDRepository { - Task> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = false); + Task> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = true); - Task> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = false); + Task> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = true); - Task ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = false); + Task ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true); - Task ReadAccessCodeAsync(string uuid, string signature, bool readOnly = false); + Task ReadAccessCodeAsync(string uuid, string signature, bool readOnly = true); Task CountAsync(string uuid, string signature); - Task ReadByIdAsync(int envelopeId, int receiverId, bool readOnly = false); + Task ReadByIdAsync(int envelopeId, int receiverId, bool readOnly = true); - Task ReadAccessCodeByIdAsync(int envelopeId, int receiverId, bool readOnly = false); + Task ReadAccessCodeByIdAsync(int envelopeId, int receiverId, bool readOnly = true); Task> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses); diff --git a/EnvelopeGenerator.Infrastructure/Repositories/EnvlopeReceiverRepository.cs b/EnvelopeGenerator.Infrastructure/Repositories/EnvlopeReceiverRepository.cs index 80c0970c..9bfb26e4 100644 --- a/EnvelopeGenerator.Infrastructure/Repositories/EnvlopeReceiverRepository.cs +++ b/EnvelopeGenerator.Infrastructure/Repositories/EnvlopeReceiverRepository.cs @@ -11,7 +11,7 @@ namespace EnvelopeGenerator.Infrastructure.Repositories { } - private IQueryable ReadWhere(string? uuid = null, string? signature = null, bool withEnvelope = false, bool withReceiver = false, bool readOnly = false) + private IQueryable ReadWhere(string? uuid = null, string? signature = null, bool withEnvelope = false, bool withReceiver = false, bool readOnly = true) { var query = readOnly ? _dbSet.AsNoTracking() : _dbSet; @@ -32,33 +32,33 @@ namespace EnvelopeGenerator.Infrastructure.Repositories return query; } - public async Task> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = false) + public async Task> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = true) => await ReadWhere(uuid: uuid, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly).ToListAsync(); - public async Task> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = false) + public async Task> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = true) => await ReadWhere(signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly).ToListAsync(); - public async Task ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = false) + public async Task ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true) => await ReadWhere(uuid: uuid, signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly).FirstOrDefaultAsync(); - public async Task ReadAccessCodeAsync(string uuid, string signature, bool readOnly = false) + public async Task ReadAccessCodeAsync(string uuid, string signature, bool readOnly = true) => await ReadWhere(uuid: uuid, signature: signature, readOnly: readOnly) .Select(er => er.AccessCode) .FirstOrDefaultAsync(); public async Task CountAsync(string uuid, string signature) => await ReadWhere(uuid: uuid, signature: signature).CountAsync(); - private IQueryable ReadById(int envelopeId, int receiverId, bool readOnly = false) + private IQueryable ReadById(int envelopeId, int receiverId, bool readOnly = true) { var query = readOnly ? _dbSet.AsNoTracking() : _dbSet; return query.Where(er => er.EnvelopeId == envelopeId && er.ReceiverId == receiverId); } - public async Task ReadByIdAsync(int envelopeId, int receiverId, bool readOnly = false) + public async Task ReadByIdAsync(int envelopeId, int receiverId, bool readOnly = true) => await ReadById(envelopeId: envelopeId, receiverId: receiverId, readOnly: readOnly) .FirstOrDefaultAsync(); - public async Task ReadAccessCodeByIdAsync(int envelopeId, int receiverId, bool readOnly = false) + public async Task ReadAccessCodeByIdAsync(int envelopeId, int receiverId, bool readOnly = true) => await ReadById(envelopeId: envelopeId, receiverId: receiverId, readOnly: readOnly) .Select(er => er.AccessCode) .FirstOrDefaultAsync();