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