feat(repository): Async-Read-Methode und Username-Filter in ProfileControlsTFRepository hinzugefügt

- `ReadAsync`-Methode für asynchrone Abfrageausführung hinzugefügt.
- `username`-Filter zur `Read`-Methode hinzugefügt.
- Filterlogik in der `Read`-Methode aktualisiert, um die `username`-Bedingung einzuschließen.
This commit is contained in:
Developer 02 2024-10-23 13:11:27 +02:00
parent 845f7fe729
commit e0877f5990
2 changed files with 8 additions and 1 deletions

View File

@ -5,5 +5,6 @@ namespace WorkFlow.Infrastructure.Contracts
{
public interface IProfileControlsTFRepository : ICRUDRepository<ProfileControlsTF, int>
{
Task<IEnumerable<ProfileControlsTF>> ReadAsync(bool withProfile = true, bool withUser = false, int? profileId = null, int? objId = null, bool? profileActive = null);
}
}

View File

@ -8,7 +8,7 @@ namespace WorkFlow.Infrastructure.Repositories
{
public class ProfileControlsTFRepository(WFDBContext dbContext) : CRUDRepository<ProfileControlsTF, int, WFDBContext>(dbContext, dbContext.ProfileControlsTFs), IProfileControlsTFRepository, ICRUDRepository<ProfileControlsTF, int>
{
protected IQueryable<ProfileControlsTF> Read(bool isReadonly = false, bool withProfile = true, bool withUser = false, int? profileId = null, int? usrId = null, int? objId = null, bool? profileActive = null)
protected IQueryable<ProfileControlsTF> Read(bool isReadonly = false, bool withProfile = true, bool withUser = false, int? profileId = null, int? usrId = null, string? username = null, int? objId = null, bool? profileActive = null)
{
var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable();
@ -24,6 +24,9 @@ namespace WorkFlow.Infrastructure.Repositories
if (usrId is not null)
query = query.Where(pctf => pctf.UsrId == usrId);
if (username is null)
query = query.Where(pctf => pctf.User!.Username == username);
if (objId is not null)
query = query.Where(pctf => pctf.ObjId == objId);
@ -32,5 +35,8 @@ namespace WorkFlow.Infrastructure.Repositories
return query;
}
public async Task<IEnumerable<ProfileControlsTF>> ReadAsync(bool withProfile = true, bool withUser = false, int? profileId = null, int? objId = null, bool? profileActive = null)
=> await Read(withProfile: withProfile, withUser: withUser, profileId: profileId, objId: objId, profileActive: profileActive).ToListAsync();
}
}