feat(EnvelopeReceiverRepository): Optionale schreibgeschützte Eingabe als Schnittstellenimplementierung hinzugefügt.
- Standardmäßig ist schreibgeschützt falsch.
This commit is contained in:
parent
085f37de16
commit
f0f1275e75
@ -5,19 +5,19 @@ namespace EnvelopeGenerator.Infrastructure.Contracts
|
||||
{
|
||||
public interface IEnvelopeReceiverRepository : ICRUDRepository<EnvelopeReceiver, (int Envelope, int Receiver)>
|
||||
{
|
||||
Task<IEnumerable<EnvelopeReceiver>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false);
|
||||
Task<IEnumerable<EnvelopeReceiver>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = false);
|
||||
|
||||
Task<IEnumerable<EnvelopeReceiver>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true);
|
||||
Task<IEnumerable<EnvelopeReceiver>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = false);
|
||||
|
||||
Task<EnvelopeReceiver?> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true);
|
||||
Task<EnvelopeReceiver?> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = false);
|
||||
|
||||
Task<string?> ReadAccessCodeAsync(string uuid, string signature);
|
||||
Task<string?> ReadAccessCodeAsync(string uuid, string signature, bool readOnly = false);
|
||||
|
||||
Task<int> CountAsync(string uuid, string signature);
|
||||
|
||||
Task<EnvelopeReceiver?> ReadByIdAsync(int envelopeId, int receiverId);
|
||||
Task<EnvelopeReceiver?> ReadByIdAsync(int envelopeId, int receiverId, bool readOnly = false);
|
||||
|
||||
Task<string?> ReadAccessCodeByIdAsync(int envelopeId, int receiverId);
|
||||
Task<string?> ReadAccessCodeByIdAsync(int envelopeId, int receiverId, bool readOnly = false);
|
||||
|
||||
Task<IEnumerable<EnvelopeReceiver>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses);
|
||||
|
||||
|
||||
@ -11,9 +11,9 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
|
||||
{
|
||||
}
|
||||
|
||||
private IQueryable<EnvelopeReceiver> ReadWhere(string? uuid = null, string? signature = null, bool withEnvelope = false, bool withReceiver = false)
|
||||
private IQueryable<EnvelopeReceiver> ReadWhere(string? uuid = null, string? signature = null, bool withEnvelope = false, bool withReceiver = false, bool readOnly = false)
|
||||
{
|
||||
var query = _dbSet.AsNoTracking();
|
||||
var query = readOnly ? _dbSet.AsNoTracking() : _dbSet;
|
||||
|
||||
if (uuid is not null)
|
||||
query = query.Where(er => er.Envelope != null && er.Envelope.Uuid == uuid);
|
||||
@ -32,31 +32,34 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
|
||||
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>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = false)
|
||||
=> await ReadWhere(uuid: uuid, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly).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<IEnumerable<EnvelopeReceiver>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = false)
|
||||
=> await ReadWhere(signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly).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<EnvelopeReceiver?> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = false)
|
||||
=> await ReadWhere(uuid: uuid, signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly).FirstOrDefaultAsync();
|
||||
|
||||
public async Task<string?> ReadAccessCodeAsync(string uuid, string signature)
|
||||
=> await ReadWhere(uuid: uuid, signature: signature)
|
||||
public async Task<string?> ReadAccessCodeAsync(string uuid, string signature, bool readOnly = false)
|
||||
=> await ReadWhere(uuid: uuid, signature: signature, readOnly: readOnly)
|
||||
.Select(er => er.AccessCode)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
public async Task<int> CountAsync(string uuid, string signature) => await ReadWhere(uuid: uuid, signature: signature).CountAsync();
|
||||
|
||||
public IQueryable<EnvelopeReceiver> ReadById(int envelopeId, int receiverId) => _dbSet.AsNoTracking()
|
||||
.Where(er => er.EnvelopeId == envelopeId && er.ReceiverId == receiverId);
|
||||
private IQueryable<EnvelopeReceiver> ReadById(int envelopeId, int receiverId, bool readOnly = false)
|
||||
{
|
||||
var query = readOnly ? _dbSet.AsNoTracking() : _dbSet;
|
||||
return query.Where(er => er.EnvelopeId == envelopeId && er.ReceiverId == receiverId);
|
||||
}
|
||||
|
||||
public async Task<EnvelopeReceiver?> ReadByIdAsync(int envelopeId, int receiverId)
|
||||
=> await ReadById(envelopeId: envelopeId, receiverId: receiverId)
|
||||
public async Task<EnvelopeReceiver?> ReadByIdAsync(int envelopeId, int receiverId, bool readOnly = false)
|
||||
=> await ReadById(envelopeId: envelopeId, receiverId: receiverId, readOnly: readOnly)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
public async Task<string?> ReadAccessCodeByIdAsync(int envelopeId, int receiverId)
|
||||
=> await ReadById(envelopeId: envelopeId, receiverId: receiverId)
|
||||
public async Task<string?> ReadAccessCodeByIdAsync(int envelopeId, int receiverId, bool readOnly = false)
|
||||
=> await ReadById(envelopeId: envelopeId, receiverId: receiverId, readOnly: readOnly)
|
||||
.Select(er => er.AccessCode)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user