From 10b557374df833be73306e048787491d2442216a Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Thu, 13 Mar 2025 10:04:40 +0100 Subject: [PATCH] =?UTF-8?q?chore:=20Hinzuf=C3=BCgen=20von=20.net=207-Unter?= =?UTF-8?q?st=C3=BCtzung=20f=C3=BCr=20Dom=C3=A4ne,=20Infrastruktur=20und?= =?UTF-8?q?=20Anwendung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/ConfigService.cs | 9 ++- .../Services/ProfileControlsTFService.cs | 7 +- .../Services/ProfileObjStateService.cs | 36 +++++---- .../Services/ProfileService.cs | 9 ++- WorkFlow.Application/Services/StateService.cs | 9 ++- .../WorkFlow.Application.csproj | 2 +- WorkFlow.Domain/WorkFlow.Domain.csproj | 2 +- .../Repositories/ConfigRepository.cs | 5 +- .../ProfileControlsTFRepository.cs | 6 +- .../Repositories/ProfileObjStateRepository.cs | 77 ++++++++++--------- .../Repositories/ProfileRepository.cs | 6 +- .../Repositories/StateRepository.cs | 7 +- WorkFlow.Infrastructure/WFDBContext.cs | 45 ++++++----- .../WorkFlow.Infrastructure.csproj | 2 +- 14 files changed, 124 insertions(+), 98 deletions(-) diff --git a/WorkFlow.Application/Services/ConfigService.cs b/WorkFlow.Application/Services/ConfigService.cs index 3a3fe2e..f8bc802 100644 --- a/WorkFlow.Application/Services/ConfigService.cs +++ b/WorkFlow.Application/Services/ConfigService.cs @@ -6,11 +6,12 @@ using WorkFlow.Application.DTO.Config; using WorkFlow.Domain.Entities; using WorkFlow.Infrastructure.Contracts; -namespace WorkFlow.Application.Services +namespace WorkFlow.Application.Services; + +public class ConfigService : CRUDService, + IConfigService, ICRUDService { - public class ConfigService(IConfigRepository repository, IMapper mapper) - : CRUDService(repository, mapper), - IConfigService, ICRUDService + public ConfigService(IConfigRepository repository, IMapper mapper) : base(repository, mapper) { } } \ No newline at end of file diff --git a/WorkFlow.Application/Services/ProfileControlsTFService.cs b/WorkFlow.Application/Services/ProfileControlsTFService.cs index 23058cc..9740af6 100644 --- a/WorkFlow.Application/Services/ProfileControlsTFService.cs +++ b/WorkFlow.Application/Services/ProfileControlsTFService.cs @@ -9,10 +9,13 @@ using WorkFlow.Infrastructure.Contracts; namespace WorkFlow.Application.Services { - public class ProfileControlsTFService(IProfileControlsTFRepository repository, IMapper mapper) - : CRUDService(repository, mapper), + public class ProfileControlsTFService : CRUDService, IProfileControlsTFService, ICRUDService { + public ProfileControlsTFService(IProfileControlsTFRepository repository, IMapper mapper) : base(repository, mapper) + { + } + public async Task>> ReadAsync( bool withProfile = true, bool withUser = false, int? userId = null, string? username = null, diff --git a/WorkFlow.Application/Services/ProfileObjStateService.cs b/WorkFlow.Application/Services/ProfileObjStateService.cs index 4058681..bde4e78 100644 --- a/WorkFlow.Application/Services/ProfileObjStateService.cs +++ b/WorkFlow.Application/Services/ProfileObjStateService.cs @@ -7,26 +7,28 @@ using WorkFlow.Application.DTO.ProfileObjState; using WorkFlow.Domain.Entities; using WorkFlow.Infrastructure.Contracts; -namespace WorkFlow.Application.Services +namespace WorkFlow.Application.Services; + +public class ProfileObjStateService : CRUDService, + IProfileObjStateService, ICRUDService { - public class ProfileObjStateService(IProfileObjStateRepository repository, IMapper mapper) - : CRUDService(repository, mapper), - IProfileObjStateService, ICRUDService + public ProfileObjStateService(IProfileObjStateRepository repository, IMapper mapper) : base(repository, mapper) + { + } + + public async Task>> ReadAsync( + bool withProfile = true, bool withUser = true, bool withState = true, + int? userId = null, string? username = null, + int? profileId = null, int? objId = null, bool? profileActive = null) { - public async Task>> ReadAsync( - bool withProfile = true, bool withUser = true, bool withState = true, - int? userId = null, string? username = null, - int? profileId = null, int? objId = null, bool? profileActive = null) - { - var pos_list = await _repository.ReadAsync( - isReadonly: true, - withProfile: withProfile, withUser: withUser, withState: withState, - userId: userId, username: username, - profileId: profileId, objId: objId, profileActive: profileActive); + var pos_list = await _repository.ReadAsync( + isReadonly: true, + withProfile: withProfile, withUser: withUser, withState: withState, + userId: userId, username: username, + profileId: profileId, objId: objId, profileActive: profileActive); - var post_dto_list = _mapper.Map>(pos_list); + var post_dto_list = _mapper.Map>(pos_list); - return Result.Success(post_dto_list); - } + return Result.Success(post_dto_list); } } \ No newline at end of file diff --git a/WorkFlow.Application/Services/ProfileService.cs b/WorkFlow.Application/Services/ProfileService.cs index 3e1cdac..cd21475 100644 --- a/WorkFlow.Application/Services/ProfileService.cs +++ b/WorkFlow.Application/Services/ProfileService.cs @@ -5,11 +5,12 @@ using WorkFlow.Application.DTO.Profile; using WorkFlow.Domain.Entities; using WorkFlow.Infrastructure.Contracts; -namespace WorkFlow.Application.Services +namespace WorkFlow.Application.Services; + +public class ProfileService : CRUDService, + IProfileService, ICRUDService { - public class ProfileService(IProfileRepository repository, AutoMapper.IMapper mapper) - : CRUDService(repository, mapper), - IProfileService, ICRUDService + public ProfileService(IProfileRepository repository, AutoMapper.IMapper mapper) : base(repository, mapper) { } } \ No newline at end of file diff --git a/WorkFlow.Application/Services/StateService.cs b/WorkFlow.Application/Services/StateService.cs index a1c162d..7f02694 100644 --- a/WorkFlow.Application/Services/StateService.cs +++ b/WorkFlow.Application/Services/StateService.cs @@ -6,11 +6,12 @@ using WorkFlow.Application.DTO.State; using WorkFlow.Domain.Entities; using WorkFlow.Infrastructure.Contracts; -namespace WorkFlow.Application.Services +namespace WorkFlow.Application.Services; + +public class StateService : CRUDService, + IStateService, ICRUDService { - public class StateService(IStateRepository repository, IMapper mapper) - : CRUDService(repository, mapper), - IStateService, ICRUDService + public StateService(IStateRepository repository, IMapper mapper) : base(repository, mapper) { } } \ No newline at end of file diff --git a/WorkFlow.Application/WorkFlow.Application.csproj b/WorkFlow.Application/WorkFlow.Application.csproj index 2ef316c..fe2c08d 100644 --- a/WorkFlow.Application/WorkFlow.Application.csproj +++ b/WorkFlow.Application/WorkFlow.Application.csproj @@ -1,7 +1,7 @@  - net8.0 + net7.0;net8.0 enable enable diff --git a/WorkFlow.Domain/WorkFlow.Domain.csproj b/WorkFlow.Domain/WorkFlow.Domain.csproj index c512782..1d1a2c3 100644 --- a/WorkFlow.Domain/WorkFlow.Domain.csproj +++ b/WorkFlow.Domain/WorkFlow.Domain.csproj @@ -1,7 +1,7 @@  - net8.0 + net7.0;net8.0 enable enable diff --git a/WorkFlow.Infrastructure/Repositories/ConfigRepository.cs b/WorkFlow.Infrastructure/Repositories/ConfigRepository.cs index 7353064..1db8625 100644 --- a/WorkFlow.Infrastructure/Repositories/ConfigRepository.cs +++ b/WorkFlow.Infrastructure/Repositories/ConfigRepository.cs @@ -6,7 +6,10 @@ using WorkFlow.Infrastructure.Contracts; namespace WorkFlow.Infrastructure.Repositories { //TODO: Make the db context type generic so that it can be used by other projects with different db contexts. - public class ConfigRepository(WFDBContext dbContext) : CRUDRepository(dbContext, dbContext.Configs), IConfigRepository, ICRUDRepository + public class ConfigRepository : CRUDRepository, IConfigRepository, ICRUDRepository { + public ConfigRepository(WFDBContext dbContext) : base(dbContext, dbContext.Configs) + { + } } } \ No newline at end of file diff --git a/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs b/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs index 5118a93..6f0b05d 100644 --- a/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs +++ b/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs @@ -6,8 +6,12 @@ using WorkFlow.Infrastructure.Contracts; namespace WorkFlow.Infrastructure.Repositories { - public class ProfileControlsTFRepository(WFDBContext dbContext) : CRUDRepository(dbContext, dbContext.ProfileControlsTFs), IProfileControlsTFRepository, ICRUDRepository + public class ProfileControlsTFRepository : CRUDRepository, IProfileControlsTFRepository, ICRUDRepository { + public ProfileControlsTFRepository(WFDBContext dbContext) : base(dbContext, dbContext.ProfileControlsTFs) + { + } + 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) diff --git a/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs b/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs index a041aec..f8034db 100644 --- a/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs +++ b/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs @@ -4,56 +4,59 @@ using Microsoft.EntityFrameworkCore; using WorkFlow.Domain.Entities; using WorkFlow.Infrastructure.Contracts; -namespace WorkFlow.Infrastructure.Repositories +namespace WorkFlow.Infrastructure.Repositories; + +public class ProfileObjStateRepository : CRUDRepository, IProfileObjStateRepository, ICRUDRepository { - public class ProfileObjStateRepository(WFDBContext dbContext) : CRUDRepository(dbContext, dbContext.ProfileObjStates), IProfileObjStateRepository, ICRUDRepository + public ProfileObjStateRepository(WFDBContext dbContext) : base(dbContext, dbContext.ProfileObjStates) { - protected override IQueryable ReadOnly() => base.ReadOnly().Include(pos => pos.Profile).Include(pos => pos.State); + } - protected IQueryable Read(bool isReadonly = false, bool withProfile = true, bool withUser = true, bool withState = true, int? profileId = null, int? userId = null, string? username = null, int? stateId = null, int? objId = null, bool? profileActive = null) - { - var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable(); + protected override IQueryable ReadOnly() => base.ReadOnly().Include(pos => pos.Profile).Include(pos => pos.State); - if (withProfile) - query = query.Include(pctf => pctf.Profile); + protected IQueryable Read(bool isReadonly = false, bool withProfile = true, bool withUser = true, bool withState = true, int? profileId = null, int? userId = null, string? username = null, int? stateId = null, int? objId = null, bool? profileActive = null) + { + var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable(); - if (withUser) - query = query.Include(pctf => pctf.User); + if (withProfile) + query = query.Include(pctf => pctf.Profile); - if (withState) - query = query.Include(pctf => pctf.State); + if (withUser) + query = query.Include(pctf => pctf.User); - if (profileId is not null) - query = query.Where(pctf => pctf.ProfileId == profileId); + if (withState) + query = query.Include(pctf => pctf.State); - if (userId is not null) - query = query.Where(pctf => pctf.UserId == userId); + if (profileId is not null) + query = query.Where(pctf => pctf.ProfileId == profileId); - if (username is null) - query = query.Where(pctf => pctf.User!.Username == username); + if (userId is not null) + query = query.Where(pctf => pctf.UserId == userId); - if (stateId is null) - query = query.Where(pctf => pctf.State!.Id == stateId); + 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 (stateId is null) + query = query.Where(pctf => pctf.State!.Id == stateId); - if (profileActive is not null) - query = query.Where(pctf => pctf.Profile!.Active == profileActive); + if (objId is not null) + query = query.Where(pctf => pctf.ObjId == objId); - return query; - } + if (profileActive is not null) + query = query.Where(pctf => pctf.Profile!.Active == profileActive); - public async Task> ReadAsync( - bool isReadonly = true, - bool withProfile = true, bool withUser = true, bool withState = true, - int? userId = null, string? username = null, - int? profileId = null, int? objId = null, bool? profileActive = null) - => await Read( - isReadonly: isReadonly, - withProfile: withProfile, withUser: withUser, withState: withState, - userId: userId, username: username, - profileId: profileId, objId: objId, profileActive: profileActive) - .ToListAsync(); + return query; } + + public async Task> ReadAsync( + bool isReadonly = true, + bool withProfile = true, bool withUser = true, bool withState = true, + int? userId = null, string? username = null, + int? profileId = null, int? objId = null, bool? profileActive = null) + => await Read( + isReadonly: isReadonly, + withProfile: withProfile, withUser: withUser, withState: withState, + userId: userId, username: username, + profileId: profileId, objId: objId, profileActive: profileActive) + .ToListAsync(); } \ No newline at end of file diff --git a/WorkFlow.Infrastructure/Repositories/ProfileRepository.cs b/WorkFlow.Infrastructure/Repositories/ProfileRepository.cs index 23e5601..ad01a3a 100644 --- a/WorkFlow.Infrastructure/Repositories/ProfileRepository.cs +++ b/WorkFlow.Infrastructure/Repositories/ProfileRepository.cs @@ -3,9 +3,11 @@ using DigitalData.Core.Infrastructure; using WorkFlow.Domain.Entities; using WorkFlow.Infrastructure.Contracts; -namespace WorkFlow.Infrastructure.Repositories +namespace WorkFlow.Infrastructure.Repositories; + +public class ProfileRepository : CRUDRepository, IProfileRepository, ICRUDRepository { - public class ProfileRepository(WFDBContext dbContext) : CRUDRepository(dbContext, dbContext.Profiles), IProfileRepository, ICRUDRepository + public ProfileRepository(WFDBContext dbContext) : base(dbContext, dbContext.Profiles) { } } \ No newline at end of file diff --git a/WorkFlow.Infrastructure/Repositories/StateRepository.cs b/WorkFlow.Infrastructure/Repositories/StateRepository.cs index c35feff..b0e02b8 100644 --- a/WorkFlow.Infrastructure/Repositories/StateRepository.cs +++ b/WorkFlow.Infrastructure/Repositories/StateRepository.cs @@ -2,9 +2,12 @@ using DigitalData.Core.Infrastructure; using WorkFlow.Domain.Entities; using WorkFlow.Infrastructure.Contracts; -namespace WorkFlow.Infrastructure.Repositories + +namespace WorkFlow.Infrastructure.Repositories; + +public class StateRepository : CRUDRepository, IStateRepository, ICRUDRepository { - public class StateRepository(WFDBContext dbContext) : CRUDRepository(dbContext, dbContext.States), IStateRepository, ICRUDRepository + public StateRepository(WFDBContext dbContext) : base(dbContext, dbContext.States) { } } \ No newline at end of file diff --git a/WorkFlow.Infrastructure/WFDBContext.cs b/WorkFlow.Infrastructure/WFDBContext.cs index a534938..11f891e 100644 --- a/WorkFlow.Infrastructure/WFDBContext.cs +++ b/WorkFlow.Infrastructure/WFDBContext.cs @@ -4,40 +4,43 @@ using DigitalData.UserManager.Infrastructure.Contracts; using Microsoft.EntityFrameworkCore; using WorkFlow.Domain.Entities; -namespace WorkFlow.Infrastructure +namespace WorkFlow.Infrastructure; + +public class WFDBContext : DbContext, IUserManagerDbContext { - public class WFDBContext(DbContextOptions options) : DbContext(options), IUserManagerDbContext - { - public DbSet Configs { get; set; } + public DbSet Configs { get; set; } + + public DbSet ProfileControlsTFs { get; set; } - public DbSet ProfileControlsTFs { get; set; } + public DbSet Profiles { get; set; } - public DbSet Profiles { get; set; } + public DbSet ProfileObjStates { get; set; } - public DbSet ProfileObjStates { get; set; } + public DbSet States { get; set; } - public DbSet States { get; set; } + public DbSet GroupOfUsers { get; set; } - public DbSet GroupOfUsers { get; set; } + public DbSet Groups { get; set; } - public DbSet Groups { get; set; } + public DbSet ModuleOfUsers { get; set; } - public DbSet ModuleOfUsers { get; set; } + public DbSet Modules { get; set; } - public DbSet Modules { get; set; } + public DbSet Users { get; set; } - public DbSet Users { get; set; } + public DbSet UserReps { get; set; } - public DbSet UserReps { get; set; } + public DbSet ClientUsers { get; set; } - public DbSet ClientUsers { get; set; } + public WFDBContext(DbContextOptions options) : base(options) + { + } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - //configure model builder for user manager tables - modelBuilder.ConfigureUserManager(); + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + //configure model builder for user manager tables + modelBuilder.ConfigureUserManager(); - base.OnModelCreating(modelBuilder); - } + base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/WorkFlow.Infrastructure/WorkFlow.Infrastructure.csproj b/WorkFlow.Infrastructure/WorkFlow.Infrastructure.csproj index 0283257..0520a40 100644 --- a/WorkFlow.Infrastructure/WorkFlow.Infrastructure.csproj +++ b/WorkFlow.Infrastructure/WorkFlow.Infrastructure.csproj @@ -1,7 +1,7 @@  - net8.0 + net7.0;net8.0 enable enable