diff --git a/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs b/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs index 0941954..8442870 100644 --- a/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs +++ b/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs @@ -10,7 +10,7 @@ namespace WorkFlow.Infrastructure.Repositories { protected override IQueryable ReadOnly() => base.ReadOnly().Include(pctf => pctf.Profile).Include(pctf => pctf.User); - 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) + protected IQueryable Read(bool isReadonly = false, bool withProfile = true, bool withUser = true, int? profileId = null, int? usrId = null, string? username = null, int? objId = null, bool? profileActive = null) { var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable(); diff --git a/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs b/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs index 849a75a..5d88fe0 100644 --- a/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs +++ b/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs @@ -10,6 +10,38 @@ namespace WorkFlow.Infrastructure.Repositories { protected override IQueryable ReadOnly() => base.ReadOnly().Include(pos => pos.Profile).Include(pos => pos.State); + protected IQueryable Read(bool isReadonly = false, bool withProfile = true, bool withUser = true, bool withState = true, int? profileId = null, int? usrId = null, string? username = null, int? stateId = null, int? objId = null, bool? profileActive = null) + { + var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable(); + if (withProfile) + query = query.Include(pctf => pctf.Profile); + + if (withUser) + query = query.Include(pctf => pctf.User); + + if (withState) + query = query.Include(pctf => pctf.State); + + if (profileId is not null) + query = query.Where(pctf => pctf.ProfileId == profileId); + + 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 (stateId is null) + query = query.Where(pctf => pctf.State!.Id == stateId); + + if (objId is not null) + query = query.Where(pctf => pctf.ObjId == objId); + + if (profileActive is not null) + query = query.Where(pctf => pctf.Profile!.Active == profileActive); + + return query; + } } } \ No newline at end of file