- Die Spalte `right_group` aus der `Representation`-Entität entfernt, um die Zuordnung von Benutzern oder Gruppen zu spezifischen Gruppen zu entfernen. - Stattdessen wurde die `group`-Eigenschaft hinzugefügt, um flexible Zuordnungen zu ermöglichen. - Ermöglicht nun `user-user`, `user-group`, `group-user` und `group-group` Repräsentationen.
44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using DigitalData.Core.Infrastructure;
|
|
using DigitalData.UserManager.Domain.Entities;
|
|
using DigitalData.UserManager.Infrastructure.Contracts;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace DigitalData.UserManager.Infrastructure.Repositories
|
|
{
|
|
public class UserRepRepository<TDbContext> : CRUDRepository<UserRep, int, TDbContext>, IUserRepRepository
|
|
where TDbContext : DbContext
|
|
{
|
|
public UserRepRepository(TDbContext dbContext) : base(dbContext)
|
|
{
|
|
}
|
|
|
|
public async Task<IEnumerable<UserRep>> ReadAllAsync(bool withUser = false, bool withRepGroup = false, bool withGroup = false, bool withRepUser = false, int? userId = null, int? groupId = null)
|
|
{
|
|
var query = _dbSet.AsNoTracking();
|
|
|
|
if (withUser)
|
|
query = query.Include(ur => ur.User);
|
|
|
|
if (withRepGroup)
|
|
query = query.Include(ur => ur.RepGroup);
|
|
|
|
if (withGroup)
|
|
query = query.Include(ur => ur.Group);
|
|
|
|
if (withRepUser)
|
|
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);
|
|
}
|
|
|
|
return await query.ToListAsync();
|
|
}
|
|
}
|
|
} |