refactor: remove legacy services and controllers

This commit is contained in:
2025-07-30 15:39:30 +02:00
parent 5466b35b95
commit 13acf6de08
27 changed files with 8 additions and 604 deletions

View File

@@ -1,39 +0,0 @@
using DigitalData.Core.API;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using WorkFlow.API.Attributes;
using WorkFlow.Application.Contracts;
using WorkFlow.Application.Dto.Config;
using WorkFlow.Domain.Entities;
namespace WorkFlow.API.Controllers;
[APIKeyAuth]
[Route("api/[controller]")]
[ApiController]
[Authorize]
[Obsolete("Use MediatR")]
public class ConfigController : CRUDControllerBaseWithErrorHandling<IConfigService, ConfigCreateDto, ConfigDto, ConfigUpdateDto, Config, int>
{
public ConfigController(ILogger<ConfigController> logger, IConfigService service) : base(logger, service)
{
}
[NonAction]
public override Task<IActionResult> Create(ConfigCreateDto createDto)
{
return base.Create(createDto);
}
[NonAction]
public override Task<IActionResult> Update(ConfigUpdateDto updateDto)
{
return base.Update(updateDto);
}
[NonAction]
public override Task<IActionResult> Delete([FromRoute] int id)
{
return base.Delete(id);
}
}

View File

@@ -1,81 +0,0 @@
using DigitalData.Core.Abstraction.Application.DTO;
using DigitalData.Core.API;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using WorkFlow.API.Attributes;
using WorkFlow.Application.Contracts;
using WorkFlow.Application.Dto.ProfileControlsTF;
using WorkFlow.Domain.Entities;
namespace WorkFlow.API.Controllers;
[APIKeyAuth]
[Route("api/[controller]")]
[ApiController]
[Authorize]
[Obsolete("Use MediatR")]
public class ProfileControlsTFController : CRUDControllerBase<IProfileControlsTFService, ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTFUpdateDto, ProfileControlsTF, long>
{
public ProfileControlsTFController(ILogger<ProfileControlsTFController> logger, IProfileControlsTFService service) : base(logger, service)
{
}
[NonAction]
public override Task<IActionResult> GetAll() => base.GetAll();
[NonAction]
[HttpPut]
public override Task<IActionResult> Update(ProfileControlsTFUpdateDto updateDto) => base.Update(updateDto);
[NonAction]
[HttpPost]
public override async Task<IActionResult> Create([FromBody] ProfileControlsTFCreateDto createDto)
{
try
{
if (!User.TryGetUserId(out var id))
{
_logger.LogError("Authorization failed: User ID claim not found.");
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
}
if (createDto.UserId != id)
return Unauthorized();
return await base.Create(createDto);
}
catch (Exception ex)
{
_logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
}
}
[NonAction]
[HttpDelete]
public override async Task<IActionResult> Delete([FromRoute] long id)
{
try
{
if (!User.TryGetUserId(out var userId))
{
_logger.LogError("Authorization failed: User ID claim not found.");
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
}
return await _service.ReadByIdAsync(id).ThenAsync(
SuccessAsync: async pctf => pctf.UserId == userId ? await base.Delete(id) : Unauthorized(),
Fail: IActionResult (msg, ntc) =>
{
_logger.LogNotice(ntc);
return ntc.HasFlag(Flag.NotFound) ? NotFound() : StatusCode(StatusCodes.Status500InternalServerError);
});
}
catch (Exception ex)
{
_logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
}
}
}

View File

@@ -1,112 +0,0 @@
using DigitalData.Core.Abstraction.Application.DTO;
using DigitalData.Core.API;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using WorkFlow.API.Attributes;
using WorkFlow.Application.Contracts;
using WorkFlow.Application.Dto.ProfileObjState;
using WorkFlow.Domain.Entities;
namespace WorkFlow.API.Controllers;
[APIKeyAuth]
[Route("api/[controller]")]
[ApiController]
[Authorize]
[Obsolete("Use MediatR")]
public class ProfileObjStateController : CRUDControllerBaseWithErrorHandling<IProfileObjStateService, ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjStateUpdateDto, ProfileObjState, long>
{
private readonly ILogger<ProfileObjStateController> logger;
public ProfileObjStateController(ILogger<ProfileObjStateController> logger, IProfileObjStateService service) : base(logger, service)
{
this.logger = logger;
}
[NonAction]
public override Task<IActionResult> GetAll() => base.GetAll();
[NonAction]
public override Task<IActionResult> Update(ProfileObjStateUpdateDto updateDto) => base.Update(updateDto);
[HttpGet]
public async Task<IActionResult> GetAsync(
bool withProfile = true, bool withUser = true, bool withState = true,
int? profileId = null, int? objId = null, bool? profileActive = null)
{
try
{
if (!User.TryGetUserId(out var id))
{
logger.LogError("Authorization failed: User ID claim not found.");
return Unauthorized("Failed to retrieve user identity.");
}
return await _service.ReadAsync(
withProfile: withProfile, withUser: withUser, withState,
userId: id,
profileId: profileId, objId: objId)
.ThenAsync(
Success: pctf => pctf.Any() ? Ok(pctf) : NotFound(),
Fail: IActionResult (msg, ntc) =>
{
logger.LogNotice(ntc);
return NotFound();
});
}
catch (Exception ex)
{
logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
}
}
[HttpPost]
public override async Task<IActionResult> Create([FromBody] ProfileObjStateCreateDto createDto)
{
try
{
if (!User.TryGetUserId(out var id))
{
logger.LogError("Authorization failed: User ID claim not found.");
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
}
if (createDto.UserId != id)
return Unauthorized();
return await base.Create(createDto);
}
catch (Exception ex)
{
logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
}
}
[HttpDelete]
public override async Task<IActionResult> Delete([FromRoute] long id)
{
try
{
if (!User.TryGetUserId(out var userId))
{
logger.LogError("Authorization failed: User ID claim not found.");
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
}
return await _service.ReadByIdAsync(id).ThenAsync(
SuccessAsync: async pctf => pctf.UserId == userId ? await base.Delete(id) : Unauthorized(),
Fail: IActionResult (msg, ntc) =>
{
_logger.LogNotice(ntc);
return ntc.HasFlag(Flag.NotFound) ? NotFound() : StatusCode(StatusCodes.Status500InternalServerError);
});
}
catch (Exception ex)
{
logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
}
}
}

View File

@@ -1,39 +0,0 @@
using DigitalData.Core.API;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using WorkFlow.API.Attributes;
using WorkFlow.Application.Contracts;
using WorkFlow.Application.Dto.State;
using WorkFlow.Domain.Entities;
namespace WorkFlow.API.Controllers;
[APIKeyAuth]
[Route("api/[controller]")]
[ApiController]
[Authorize]
[Obsolete("Use MediatR")]
public class StateController : CRUDControllerBaseWithErrorHandling<IStateService, StateCreateDto, StateDto, StateUpdateDto, State, int>
{
public StateController(ILogger<StateController> logger, IStateService service) : base(logger, service)
{
}
[NonAction]
public override Task<IActionResult> Create(StateCreateDto createDto)
{
return base.Create(createDto);
}
[NonAction]
public override Task<IActionResult> Update(StateUpdateDto updateDto)
{
return base.Update(updateDto);
}
[NonAction]
public override Task<IActionResult> Delete([FromRoute] int id)
{
return base.Delete(id);
}
}

View File

@@ -1,7 +1,6 @@
using WorkFlow.Application;
using Microsoft.EntityFrameworkCore;
using WorkFlow.Infrastructure;
using DigitalData.Core.API;
using DigitalData.Core.Application;
using DigitalData.UserManager.Application.DTOs.User;
using Microsoft.IdentityModel.Tokens;
@@ -51,14 +50,13 @@ try
builder.Services.AddUserManager<WFDBContext>();
builder.Services.AddCookieBasedLocalizer();
builder.Services.AddDirectorySearchService(config.GetSection("DirectorySearchOptions"));
builder.Services.AddJWTService<UserReadDto>(user => new SecurityTokenDescriptor()
{
Claims = user.ToClaimList().ToDictionary(claim => claim.Type, claim => claim.Value as object)
});
bool disableAPIKeyAuth = config.GetValue<bool>("DisableAPIKeyAuth") && builder.IsDevOrDiP();
bool disableAPIKeyAuth = config.GetValue<bool>("DisableAPIKeyAuth");
if (disableAPIKeyAuth)
builder.Services.AddAPIKeyAuth(new APIKeyAuthOptions());
else
@@ -153,7 +151,7 @@ try
lazyProvider.Factory = () => app.Services;
// Configure the HTTP request pipeline.
if (app.IsDevOrDiP() && app.Configuration.GetValue<bool>("EnableSwagger"))
if (app.Configuration.GetValue<bool>("EnableSwagger"))
{
app.UseSwagger();
app.UseSwaggerUI();
@@ -165,8 +163,6 @@ try
app.UseAuthorization();
app.UseCookieBasedLocalizer("de-DE");
app.MapControllers();
app.Run();

View File

@@ -22,7 +22,6 @@
<ItemGroup>
<PackageReference Include="DigitalData.Auth.Client" Version="1.3.7" />
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.0.0" />
<PackageReference Include="DigitalData.Core.API" Version="2.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.20" />
<PackageReference Include="NLog" Version="5.3.4" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.14" />

View File

@@ -1,10 +0,0 @@
using DigitalData.Core.Abstraction.Application;
using WorkFlow.Application.Dto.Config;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Application.Contracts;
[Obsolete("Use MediatR")]
public interface IConfigService : ICRUDService<ConfigCreateDto, ConfigDto, Config, int>
{
}

View File

@@ -1,10 +0,0 @@
using DigitalData.Core.Abstraction.Application;
using WorkFlow.Application.Dto.ProfileControlsTF;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Application.Contracts;
[Obsolete("Use MediatR")]
public interface IProfileControlsTFService : ICRUDService<ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, long>
{
}

View File

@@ -1,15 +0,0 @@
using DigitalData.Core.Abstraction.Application;
using DigitalData.Core.Abstraction.Application.DTO;
using WorkFlow.Application.Dto.ProfileObjState;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Application.Contracts;
[Obsolete("Use MediatR")]
public interface IProfileObjStateService : ICRUDService<ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, long>
{
Task<DataResult<IEnumerable<ProfileObjStateDto>>> ReadAsync(
bool withProfile = true, bool withUser = true, bool withState = true,
int? userId = null, string? username = null,
int? profileId = null, int? objId = null);
}

View File

@@ -1,10 +0,0 @@
using DigitalData.Core.Abstraction.Application;
using WorkFlow.Application.Dto.State;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Application.Contracts;
[Obsolete("Use MediatR")]
public interface IStateService : ICRUDService<StateCreateDto, StateDto, State, int>
{
}

View File

@@ -1,10 +0,0 @@
using DigitalData.Core.Abstraction.Application.Repository;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Application.Contracts.Repositories;
[Obsolete("Use IRepository")]
public interface IButtonRepository : ICRUDRepository<Button, int>
{
public Task<IEnumerable<Button>> ReadAllAsync(int profileId);
}

View File

@@ -1,9 +0,0 @@
using DigitalData.Core.Abstraction.Application.Repository;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Application.Contracts.Repositories;
[Obsolete("Use IRepository")]
public interface IConfigRepository : ICRUDRepository<Config, int>
{
}

View File

@@ -1,9 +0,0 @@
using DigitalData.Core.Abstraction.Application.Repository;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Application.Contracts.Repositories;
[Obsolete("Use IRepository")]
public interface IProfileControlsTFRepository : ICRUDRepository<ProfileControlsTF, long>
{
}

View File

@@ -1,14 +0,0 @@
using DigitalData.Core.Abstraction.Application.Repository;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Application.Contracts.Repositories;
[Obsolete("Use IRepository")]
public interface IProfileObjStateRepository : ICRUDRepository<ProfileObjState, long>
{
Task<IEnumerable<ProfileObjState>> 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);
}

View File

@@ -1,9 +0,0 @@
using DigitalData.Core.Abstraction.Application.Repository;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Application.Contracts.Repositories;
[Obsolete("Use IRepository")]
public interface IStateRepository : ICRUDRepository<State, int>
{
}

View File

@@ -1,7 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using WorkFlow.Application.Contracts;
using WorkFlow.Application.Services;
namespace WorkFlow.Application;
@@ -14,10 +11,6 @@ public static class DependencyInjection
options?.Invoke(diOptions);
services.AddAutoMapper(typeof(MappingProfile).Assembly);
services.TryAddScoped<IConfigService, ConfigService>();
services.TryAddScoped<IProfileControlsTFService, ProfileControlsTFService>();
services.TryAddScoped<IProfileObjStateService, ProfileObjStateService>();
services.TryAddScoped<IStateService, StateService>();
services.AddMediatR(cfg =>
{
cfg.RegisterServicesFromAssembly(typeof(DependencyInjection).Assembly);

View File

@@ -1,8 +1,10 @@
using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository;
using MediatR;
using WorkFlow.Application.Buttons;
using WorkFlow.Application.Contracts.Repositories;
using WorkFlow.Application.Dto;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Application.Profiles;
@@ -22,7 +24,7 @@ public class ReadProfileHandler : IRequestHandler<ReadProfileQuery, ProfileDto?>
private readonly IProfileObjRepository _objRepository;
private readonly IButtonRepository _bttnRepository;
private readonly IRepository<Button> _bttnRepository;
private readonly IMapper _mapper;
@@ -31,7 +33,7 @@ public class ReadProfileHandler : IRequestHandler<ReadProfileQuery, ProfileDto?>
/// </summary>
/// <param name="profileRepository">The profile repository used to access profile data.</param>
/// <param name="objRepository">The profile object repository used to access object data.</param>
public ReadProfileHandler(IProfileRepository profileRepository, IProfileObjRepository objRepository, IButtonRepository buttonRepository, IMapper mapper)
public ReadProfileHandler(IProfileRepository profileRepository, IProfileObjRepository objRepository, IRepository<Button> buttonRepository, IMapper mapper)
{
_profileRepository = profileRepository;
_objRepository = objRepository;
@@ -56,7 +58,7 @@ public class ReadProfileHandler : IRequestHandler<ReadProfileQuery, ProfileDto?>
if (profile?.Id is int pId)
{
var bttns = await _bttnRepository.ReadAllAsync(pId);
var bttns = await _bttnRepository.Read(b => b.ProfileId == pId).ToListAsync(cancel);
profileDto.Buttons = _mapper.Map<IEnumerable<ButtonDto>>(bttns);
}

View File

@@ -1,18 +0,0 @@
using AutoMapper;
using DigitalData.Core.Application;
using WorkFlow.Application.Contracts;
using WorkFlow.Application.Dto.Config;
using WorkFlow.Domain.Entities;
using WorkFlow.Application.Contracts.Repositories;
using DigitalData.Core.Abstraction.Application;
namespace WorkFlow.Application.Services;
[Obsolete("Use MediatR")]
public class ConfigService : CRUDService<IConfigRepository, ConfigCreateDto, ConfigDto, Config, int>,
IConfigService, ICRUDService<ConfigCreateDto, ConfigDto, Config, int>
{
public ConfigService(IConfigRepository repository, IMapper mapper) : base(repository, mapper)
{
}
}

View File

@@ -1,24 +0,0 @@
using AutoMapper;
using DigitalData.Core.Application;
using WorkFlow.Application.Contracts;
using WorkFlow.Application.Dto.ProfileControlsTF;
using WorkFlow.Domain.Entities;
using WorkFlow.Application.Contracts.Repositories;
using DigitalData.Core.Abstraction.Application;
using DigitalData.Core.Abstraction.Application.DTO;
namespace WorkFlow.Application.Services;
[Obsolete("Use MediatR")]
public class ProfileControlsTFService : CRUDService<IProfileControlsTFRepository, ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, long>,
IProfileControlsTFService, ICRUDService<ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, long>
{
public ProfileControlsTFService(IProfileControlsTFRepository repository, IMapper mapper) : base(repository, mapper)
{
}
public Task<DataResult<IEnumerable<ProfileControlsTFDto>>> ReadAsync(bool withProfile = true, bool withUser = false, int? userId = null, string? username = null, int? profileId = null, int? objId = null, bool? profileActive = null)
{
throw new NotImplementedException();
}
}

View File

@@ -1,35 +0,0 @@
using AutoMapper;
using DigitalData.Core.Application;
using WorkFlow.Application.Contracts;
using WorkFlow.Application.Dto.ProfileObjState;
using WorkFlow.Domain.Entities;
using WorkFlow.Application.Contracts.Repositories;
using DigitalData.Core.Abstraction.Application;
using DigitalData.Core.Abstraction.Application.DTO;
namespace WorkFlow.Application.Services;
[Obsolete("Use MediatR")]
public class ProfileObjStateService : CRUDService<IProfileObjStateRepository, ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, long>,
IProfileObjStateService, ICRUDService<ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, long>
{
public ProfileObjStateService(IProfileObjStateRepository repository, IMapper mapper) : base(repository, mapper)
{
}
public async Task<DataResult<IEnumerable<ProfileObjStateDto>>> ReadAsync(
bool withProfile = true, bool withUser = true, bool withState = true,
int? userId = null, string? username = null,
int? profileId = null, int? objId = null)
{
var pos_list = await _repository.ReadAsync(
isReadonly: true,
withProfile: withProfile, withUser: withUser, withState: withState,
userId: userId, username: username,
profileId: profileId, objId: objId);
var post_dto_list = _mapper.Map<IEnumerable<ProfileObjStateDto>>(pos_list);
return Result.Success(post_dto_list);
}
}

View File

@@ -1,18 +0,0 @@
using AutoMapper;
using DigitalData.Core.Application;
using WorkFlow.Application.Contracts;
using WorkFlow.Application.Dto.State;
using WorkFlow.Domain.Entities;
using WorkFlow.Application.Contracts.Repositories;
using DigitalData.Core.Abstraction.Application;
namespace WorkFlow.Application.Services;
[Obsolete("Use MediatR")]
public class StateService : CRUDService<IStateRepository, StateCreateDto, StateDto, State, int>,
IStateService, ICRUDService<StateCreateDto, StateDto, State, int>
{
public StateService(IStateRepository repository, IMapper mapper) : base(repository, mapper)
{
}
}

View File

@@ -15,17 +15,14 @@ public static class DependencyInjection
{
public static IServiceCollection AddWorkFlowRepositories(this IServiceCollection services)
{
services.TryAddScoped<IProfileControlsTFRepository, ProfileControlsTFRepository>();
services.TryAddScoped<IProfileObjStateRepository, ProfileObjStateRepository>();
services.TryAddScoped<IProfileRepository, ProfileRepository>();
services.TryAddScoped<IProfileObjRepository, ProfileObjRepository>();
services.TryAddScoped<IStateRepository, StateRepository>();
services.TryAddScoped<IButtonRepository, ButtonRepository>();
services.AddDbRepository<WFDBContext, Config>(c => c.Configs).UseAutoMapper(typeof(ConfigUpdateDto));
services.AddDbRepository<WFDBContext, ProfileControlsTF>(c => c.ProfileControlsTFs).UseAutoMapper(typeof(ProfileControlsTFUpdateDto));
services.AddDbRepository<WFDBContext, State>(c => c.States).UseAutoMapper(typeof(StateUpdateDto));
services.AddDbRepository<WFDBContext, Button>(c => c.Buttons).UseAutoMapper();
services.AddDbRepository<WFDBContext, State>(c => c.States).UseAutoMapper(typeof(StateUpdateDto));
return services;
}

View File

@@ -1,18 +0,0 @@
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Infrastructure;
using Microsoft.EntityFrameworkCore;
using WorkFlow.Application.Contracts.Repositories;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Infrastructure.Repositories;
//TODO: Make the db context type generic so that it can be used by other projects with different db contexts.
[Obsolete("Use Repository")]
public class ButtonRepository : CRUDRepository<Button, int, WFDBContext>, IButtonRepository, ICRUDRepository<Button, int>
{
public ButtonRepository(WFDBContext dbContext) : base(dbContext, dbContext.Buttons)
{
}
public async Task<IEnumerable<Button>> ReadAllAsync(int profileId) => await _dbSet.Where(b => b.ProfileId == profileId).ToListAsync();
}

View File

@@ -1,15 +0,0 @@
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Infrastructure;
using WorkFlow.Application.Contracts.Repositories;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Infrastructure.Repositories;
//TODO: Make the db context type generic so that it can be used by other projects with different db contexts.
[Obsolete("Use Repository")]
public class ConfigRepository : CRUDRepository<Config, int, WFDBContext>, IConfigRepository, ICRUDRepository<Config, int>
{
public ConfigRepository(WFDBContext dbContext) : base(dbContext, dbContext.Configs)
{
}
}

View File

@@ -1,14 +0,0 @@
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Infrastructure;
using WorkFlow.Application.Contracts.Repositories;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Infrastructure.Repositories;
[Obsolete("Use Repository")]
public class ProfileControlsTFRepository : CRUDRepository<ProfileControlsTF, long, WFDBContext>, IProfileControlsTFRepository, ICRUDRepository<ProfileControlsTF, long>
{
public ProfileControlsTFRepository(WFDBContext dbContext) : base(dbContext, dbContext.ProfileControlsTFs)
{
}
}

View File

@@ -1,60 +0,0 @@
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Infrastructure;
using Microsoft.EntityFrameworkCore;
using WorkFlow.Application.Contracts.Repositories;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Infrastructure.Repositories;
[Obsolete("Use Repository")]
public class ProfileObjStateRepository : CRUDRepository<ProfileObjState, long, WFDBContext>, IProfileObjStateRepository, ICRUDRepository<ProfileObjState, long>
{
public ProfileObjStateRepository(WFDBContext dbContext) : base(dbContext, dbContext.ProfileObjStates)
{
}
protected override IQueryable<ProfileObjState> ReadOnly() => base.ReadOnly().Include(pos => pos.Profile).Include(pos => pos.State);
protected IQueryable<ProfileObjState> 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)
{
var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable();
if (withProfile)
query = query.Include(pctf => pctf.Profile);
if (withUser)
query = query.Include(pctf => pctf.User);
if (withState)
query = query.Include(pctf => pctf.State);
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 (stateId is null)
query = query.Where(pctf => pctf.State!.Id == stateId);
if (objId is not null)
query = query.Where(pctf => pctf.ObjId == objId);
return query;
}
public async Task<IEnumerable<ProfileObjState>> 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)
=> await Read(
isReadonly: isReadonly,
withProfile: withProfile, withUser: withUser, withState: withState,
userId: userId, username: username,
profileId: profileId, objId: objId)
.ToListAsync();
}

View File

@@ -1,14 +0,0 @@
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Infrastructure;
using WorkFlow.Application.Contracts.Repositories;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Infrastructure.Repositories;
[Obsolete("Use Repository")]
public class StateRepository : CRUDRepository<State, int, WFDBContext>, IStateRepository, ICRUDRepository<State, int>
{
public StateRepository(WFDBContext dbContext) : base(dbContext, dbContext.States)
{
}
}