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
This commit is contained in:
parent
547d723f47
commit
f8be2d9f26
@ -9,6 +9,6 @@ namespace WorkFlow.Infrastructure.Contracts
|
|||||||
bool isReadonly = true,
|
bool isReadonly = true,
|
||||||
bool withProfile = true, bool withUser = true, bool withState = true,
|
bool withProfile = true, bool withUser = true, bool withState = true,
|
||||||
int? userId = null, string? username = null,
|
int? userId = null, string? username = null,
|
||||||
int? profileId = null, int? objId = null, bool? profileActive = null);
|
int? profileId = null, int? objId = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,9 +1,5 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
namespace WorkFlow.Infrastructure.Contracts;
|
||||||
using WorkFlow.Domain.Entities;
|
|
||||||
|
|
||||||
namespace WorkFlow.Infrastructure.Contracts
|
public interface IProfileRepository
|
||||||
{
|
{
|
||||||
public interface IProfileRepository : ICRUDRepository<Profile, int>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -14,7 +14,7 @@ namespace WorkFlow.Infrastructure.Repositories
|
|||||||
|
|
||||||
protected override IQueryable<ProfileControlsTF> ReadOnly() => base.ReadOnly().Include(pctf => pctf.Profile).Include(pctf => pctf.User);
|
protected override IQueryable<ProfileControlsTF> ReadOnly() => base.ReadOnly().Include(pctf => pctf.Profile).Include(pctf => pctf.User);
|
||||||
|
|
||||||
protected IQueryable<ProfileControlsTF> 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<ProfileControlsTF> 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();
|
var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable();
|
||||||
|
|
||||||
@ -36,9 +36,6 @@ namespace WorkFlow.Infrastructure.Repositories
|
|||||||
if (objId is not null)
|
if (objId is not null)
|
||||||
query = query.Where(pctf => pctf.ObjId == objId);
|
query = query.Where(pctf => pctf.ObjId == objId);
|
||||||
|
|
||||||
if (profileActive is not null)
|
|
||||||
query = query.Where(pctf => pctf.Profile!.Active == profileActive);
|
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +48,7 @@ namespace WorkFlow.Infrastructure.Repositories
|
|||||||
isReadonly: isReadonly,
|
isReadonly: isReadonly,
|
||||||
withProfile: withProfile, withUser: withUser,
|
withProfile: withProfile, withUser: withUser,
|
||||||
userId: userId, username: username,
|
userId: userId, username: username,
|
||||||
profileId: profileId, objId: objId, profileActive: profileActive)
|
profileId: profileId, objId: objId)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14,7 +14,7 @@ public class ProfileObjStateRepository : CRUDRepository<ProfileObjState, int, WF
|
|||||||
|
|
||||||
protected override IQueryable<ProfileObjState> ReadOnly() => base.ReadOnly().Include(pos => pos.Profile).Include(pos => pos.State);
|
protected override IQueryable<ProfileObjState> ReadOnly() => base.ReadOnly().Include(pos => pos.Profile).Include(pos => pos.State);
|
||||||
|
|
||||||
protected IQueryable<ProfileObjState> 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<ProfileObjState> 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();
|
var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable();
|
||||||
|
|
||||||
@ -42,9 +42,6 @@ public class ProfileObjStateRepository : CRUDRepository<ProfileObjState, int, WF
|
|||||||
if (objId is not null)
|
if (objId is not null)
|
||||||
query = query.Where(pctf => pctf.ObjId == objId);
|
query = query.Where(pctf => pctf.ObjId == objId);
|
||||||
|
|
||||||
if (profileActive is not null)
|
|
||||||
query = query.Where(pctf => pctf.Profile!.Active == profileActive);
|
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,11 +49,11 @@ public class ProfileObjStateRepository : CRUDRepository<ProfileObjState, int, WF
|
|||||||
bool isReadonly = true,
|
bool isReadonly = true,
|
||||||
bool withProfile = true, bool withUser = true, bool withState = true,
|
bool withProfile = true, bool withUser = true, bool withState = true,
|
||||||
int? userId = null, string? username = null,
|
int? userId = null, string? username = null,
|
||||||
int? profileId = null, int? objId = null, bool? profileActive = null)
|
int? profileId = null, int? objId = null)
|
||||||
=> await Read(
|
=> await Read(
|
||||||
isReadonly: isReadonly,
|
isReadonly: isReadonly,
|
||||||
withProfile: withProfile, withUser: withUser, withState: withState,
|
withProfile: withProfile, withUser: withUser, withState: withState,
|
||||||
userId: userId, username: username,
|
userId: userId, username: username,
|
||||||
profileId: profileId, objId: objId, profileActive: profileActive)
|
profileId: profileId, objId: objId)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
@ -1,13 +1,7 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
using WorkFlow.Infrastructure.Contracts;
|
||||||
using DigitalData.Core.Infrastructure;
|
|
||||||
using WorkFlow.Domain.Entities;
|
|
||||||
using WorkFlow.Infrastructure.Contracts;
|
|
||||||
|
|
||||||
namespace WorkFlow.Infrastructure.Repositories;
|
namespace WorkFlow.Infrastructure.Repositories;
|
||||||
|
|
||||||
public class ProfileRepository : CRUDRepository<Profile, int, WFDBContext>, IProfileRepository, ICRUDRepository<Profile, int>
|
public class ProfileRepository : IProfileRepository
|
||||||
{
|
{
|
||||||
public ProfileRepository(WFDBContext dbContext) : base(dbContext, dbContext.Profiles)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user