From e0877f5990282980cbf9c7487dbbf9ca95ad2bb0 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 23 Oct 2024 13:11:27 +0200 Subject: [PATCH] =?UTF-8?q?feat(repository):=20Async-Read-Methode=20und=20?= =?UTF-8?q?Username-Filter=20in=20ProfileControlsTFRepository=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `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. --- .../Contracts/IProfileControlsTFRepository.cs | 1 + .../Repositories/ProfileControlsTFRepository.cs | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/WorkFlow.Infrastructure/Contracts/IProfileControlsTFRepository.cs b/WorkFlow.Infrastructure/Contracts/IProfileControlsTFRepository.cs index c57f3d8..9a8a4c0 100644 --- a/WorkFlow.Infrastructure/Contracts/IProfileControlsTFRepository.cs +++ b/WorkFlow.Infrastructure/Contracts/IProfileControlsTFRepository.cs @@ -5,5 +5,6 @@ namespace WorkFlow.Infrastructure.Contracts { public interface IProfileControlsTFRepository : ICRUDRepository { + Task> ReadAsync(bool withProfile = true, bool withUser = false, int? profileId = null, int? objId = null, bool? profileActive = null); } } \ No newline at end of file diff --git a/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs b/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs index 2b55db8..23801cb 100644 --- a/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs +++ b/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs @@ -8,7 +8,7 @@ namespace WorkFlow.Infrastructure.Repositories { public class ProfileControlsTFRepository(WFDBContext dbContext) : CRUDRepository(dbContext, dbContext.ProfileControlsTFs), IProfileControlsTFRepository, ICRUDRepository { - protected IQueryable Read(bool isReadonly = false, bool withProfile = true, bool withUser = false, int? profileId = null, int? usrId = null, int? objId = null, bool? profileActive = null) + protected IQueryable 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> 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(); } } \ No newline at end of file