using DigitalData.Core.Abstractions.Infrastructure; using DigitalData.Core.Infrastructure; using Microsoft.EntityFrameworkCore; using WorkFlow.Domain.Entities; using WorkFlow.Infrastructure.Contracts; namespace WorkFlow.Infrastructure.Repositories { public class ProfileControlsTFRepository(WFDBContext dbContext) : CRUDRepository(dbContext, dbContext.ProfileControlsTFs), IProfileControlsTFRepository, ICRUDRepository { protected override IQueryable ReadOnly() => base.ReadOnly().Include(pctf => pctf.Profile).Include(pctf => pctf.User); protected IQueryable 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) { var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable(); if (withProfile) query = query.Include(pctf => pctf.Profile); if (withUser) query = query.Include(pctf => pctf.User); if (profileId is not null) query = query.Where(pctf => pctf.ProfileId == profileId); if (userId is not null) query = query.Where(pctf => pctf.UserId == userId); if (username is null) query = query.Where(pctf => pctf.User!.Username == username); if (objId is not null) query = query.Where(pctf => pctf.ObjId == objId); if (profileActive is not null) query = query.Where(pctf => pctf.Profile!.Active == profileActive); return query; } public async Task> ReadAsync( bool isReadonly = true, bool withProfile = true, bool withUser = true, int? userId = null, string? username = null, int? profileId = null, int? objId = null, bool? profileActive = null) => await Read( isReadonly: isReadonly, withProfile: withProfile, withUser: withUser, userId: userId, username: username, profileId: profileId, objId: objId, profileActive: profileActive) .ToListAsync(); } }