From f8be2d9f265e6b481191a85fc6878c75551e18f0 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 18 Jul 2025 16:08:08 +0200 Subject: [PATCH] refactor(repository): simplify Profile and ProfileObjState repositories - Removed inheritance from ICRUDRepository in IProfileRepository and related implementation - Cleaned up ProfileRepository to no longer extend CRUDRepository - Removed `profileActive` filter from IProfileObjStateRepository and implementation - Adjusted Read and ReadAsync methods accordingly --- .../Contracts/IProfileObjStateRepository.cs | 2 +- .../Contracts/IProfileRepository.cs | 8 ++------ .../Repositories/ProfileControlsTFRepository.cs | 7 ++----- .../Repositories/ProfileObjStateRepository.cs | 9 +++------ .../Repositories/ProfileRepository.cs | 10 ++-------- 5 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/WorkFlow.Infrastructure/Contracts/IProfileObjStateRepository.cs b/src/WorkFlow.Infrastructure/Contracts/IProfileObjStateRepository.cs index bdf88cb..aeb6c55 100644 --- a/src/WorkFlow.Infrastructure/Contracts/IProfileObjStateRepository.cs +++ b/src/WorkFlow.Infrastructure/Contracts/IProfileObjStateRepository.cs @@ -9,6 +9,6 @@ namespace WorkFlow.Infrastructure.Contracts bool isReadonly = true, bool withProfile = true, bool withUser = true, bool withState = true, int? userId = null, string? username = null, - int? profileId = null, int? objId = null, bool? profileActive = null); + int? profileId = null, int? objId = null); } } \ No newline at end of file diff --git a/src/WorkFlow.Infrastructure/Contracts/IProfileRepository.cs b/src/WorkFlow.Infrastructure/Contracts/IProfileRepository.cs index c04b116..385e384 100644 --- a/src/WorkFlow.Infrastructure/Contracts/IProfileRepository.cs +++ b/src/WorkFlow.Infrastructure/Contracts/IProfileRepository.cs @@ -1,9 +1,5 @@ -using DigitalData.Core.Abstractions.Infrastructure; -using WorkFlow.Domain.Entities; +namespace WorkFlow.Infrastructure.Contracts; -namespace WorkFlow.Infrastructure.Contracts +public interface IProfileRepository { - public interface IProfileRepository : ICRUDRepository - { - } } \ No newline at end of file diff --git a/src/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs b/src/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs index 6f0b05d..1322eb0 100644 --- a/src/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs +++ b/src/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs @@ -14,7 +14,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 = true, int? profileId = null, int? userId = 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? userId = null, string? username = null, int? objId = null) { var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable(); @@ -36,9 +36,6 @@ namespace WorkFlow.Infrastructure.Repositories 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; } @@ -51,7 +48,7 @@ namespace WorkFlow.Infrastructure.Repositories isReadonly: isReadonly, withProfile: withProfile, withUser: withUser, userId: userId, username: username, - profileId: profileId, objId: objId, profileActive: profileActive) + profileId: profileId, objId: objId) .ToListAsync(); } } \ No newline at end of file diff --git a/src/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs b/src/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs index f8034db..9b5055b 100644 --- a/src/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs +++ b/src/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs @@ -14,7 +14,7 @@ public class ProfileObjStateRepository : CRUDRepository 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? userId = null, string? username = null, int? stateId = null, int? objId = null, bool? profileActive = null) + protected IQueryable Read(bool isReadonly = false, bool withProfile = true, bool withUser = true, bool withState = true, int? profileId = null, int? userId = null, string? username = null, int? stateId = null, int? objId = null) { var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable(); @@ -42,9 +42,6 @@ public class ProfileObjStateRepository : CRUDRepository pctf.ObjId == objId); - if (profileActive is not null) - query = query.Where(pctf => pctf.Profile!.Active == profileActive); - return query; } @@ -52,11 +49,11 @@ public class ProfileObjStateRepository : CRUDRepository await Read( isReadonly: isReadonly, withProfile: withProfile, withUser: withUser, withState: withState, userId: userId, username: username, - profileId: profileId, objId: objId, profileActive: profileActive) + profileId: profileId, objId: objId) .ToListAsync(); } \ No newline at end of file diff --git a/src/WorkFlow.Infrastructure/Repositories/ProfileRepository.cs b/src/WorkFlow.Infrastructure/Repositories/ProfileRepository.cs index ad01a3a..fcbc7c9 100644 --- a/src/WorkFlow.Infrastructure/Repositories/ProfileRepository.cs +++ b/src/WorkFlow.Infrastructure/Repositories/ProfileRepository.cs @@ -1,13 +1,7 @@ -using DigitalData.Core.Abstractions.Infrastructure; -using DigitalData.Core.Infrastructure; -using WorkFlow.Domain.Entities; -using WorkFlow.Infrastructure.Contracts; +using WorkFlow.Infrastructure.Contracts; namespace WorkFlow.Infrastructure.Repositories; -public class ProfileRepository : CRUDRepository, IProfileRepository, ICRUDRepository +public class ProfileRepository : IProfileRepository { - public ProfileRepository(WFDBContext dbContext) : base(dbContext, dbContext.Profiles) - { - } } \ No newline at end of file