feat: Unterstützung für die Filterung nach RepGroupId in der ReadAllAsync-Methode hinzufügen

This commit is contained in:
Developer 02 2024-10-29 16:33:41 +01:00
parent 9e11463ef2
commit 25995e8d48
3 changed files with 9 additions and 7 deletions

View File

@ -1,6 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
namespace DigitalData.UserManager.Domain.Entities
{

View File

@ -5,6 +5,8 @@ namespace DigitalData.UserManager.Infrastructure.Contracts
{
public interface IUserRepRepository : ICRUDRepository<UserRep, int>
{
Task<IEnumerable<UserRep>> ReadAllAsync(bool withUser = false, bool withRepGroup = false, bool withGroup = false, bool withRepUser = false, int? userId = null, int? groupId = null, bool readOnly = true);
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);
}
}

View File

@ -12,7 +12,9 @@ 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, bool readOnly = true)
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)
{
var query = readOnly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable();
@ -29,14 +31,13 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
query = query.Include(ur => ur.RepUser);
if(userId is not null)
{
query = query.Where(ur => ur.UserId == userId);
}
if (groupId is not null)
{
query = query.Where(ur => ur.GroupId == groupId);
}
if (repGroupId is not null)
query = query.Where(ur => ur.RepGroupId == repGroupId);
return await query.ToListAsync();
}