feat: Unterstützung für die Filterung nach RepGroupId in der ReadAllAsync-Methode hinzufügen
This commit is contained in:
parent
9e11463ef2
commit
25995e8d48
@ -1,6 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DigitalData.UserManager.Domain.Entities
|
||||
{
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user