feat(EnvelopeReceiverService): Status-Filteroption zu ReadByUserAsync hinzugefügt, um die Ergebnisse nach Status zu filtern
This commit is contained in:
@@ -46,7 +46,20 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
|
||||
return await query.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Envelope>> ReadByUserAsync(int userId) => await _dbSet.AsNoTracking()
|
||||
.Where(e => e.UserId == userId).ToListAsync();
|
||||
public async Task<IEnumerable<Envelope>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses)
|
||||
{
|
||||
var query = _dbSet.AsNoTracking().Where(e => e.UserId == userId);
|
||||
|
||||
if (min_status is not null)
|
||||
query = query.Where(e => e.Status >= min_status);
|
||||
|
||||
if (max_status is not null)
|
||||
query = query.Where(e => e.Status <= max_status);
|
||||
|
||||
foreach (var ignore_status in ignore_statuses)
|
||||
query = query.Where(e => e.Status != ignore_status);
|
||||
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user