refactor: repUserId-Parameter zur ReadAllAsync-Methode in UserRepRepository hinzugefügt

This commit is contained in:
Developer 02 2024-10-30 16:09:35 +01:00
parent 4c02607409
commit 1273b7ac46
3 changed files with 7 additions and 3 deletions

View File

@ -7,6 +7,6 @@ namespace DigitalData.UserManager.Infrastructure.Contracts
{
Task<IEnumerable<UserRep>> ReadAllAsync(
bool withUser = false, bool withRepGroup = false, bool withGroup = false, bool withRepUser = false,
int? userId = null, int? groupId = null, int? repGroupId = null, bool readOnly = true);
int? userId = null, int? repUserId = null, int? groupId = null, int? repGroupId = null, bool readOnly = true);
}
}

View File

@ -18,6 +18,7 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
_uRepRepo = userRepRepository;
}
//TODO: instead of this implmenet .OnDelete(DeleteBehavior.ClientCascade) in DbContext
public override async Task<bool> DeleteAsync(Group group)
{
var gou_list = await _gouRepo.ReadAsync(readOnly: false, groupId: group.Id);

View File

@ -14,7 +14,7 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
public async Task<IEnumerable<UserRep>> ReadAllAsync(
bool withUser = false, bool withRepGroup = false, bool withGroup = false, bool withRepUser = false,
int? userId = null, int? groupId = null, int? repGroupId = null, bool readOnly = true)
int? userId = null, int? repUserId = null, int? groupId = null, int? repGroupId = null, bool readOnly = true)
{
var query = readOnly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable();
@ -30,9 +30,12 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
if (withRepUser)
query = query.Include(ur => ur.RepUser);
if(userId is not null)
if (userId is not null)
query = query.Where(ur => ur.UserId == userId);
if (repUserId is not null)
query = query.Where(ur => ur.RepUserId == repUserId);
if (groupId is not null)
query = query.Where(ur => ur.GroupId == groupId);