Felhasználó és szabály törlésének befejezése

This commit is contained in:
2025-04-10 13:37:39 +02:00
parent 7109da0d95
commit cd57fc46bc
16 changed files with 1218 additions and 39 deletions
@@ -11,12 +11,15 @@ namespace WorkFlowCheck.BL.Services.Interfaces
{
Task<UserDTO> GetUserAsync(int Id);
Task<List<UserDTO>> GetAllUserAsync();
Task<bool> DeleteUserAsync(int Id);
Task<UserDTO> UpdateUserAsync(UserDTO userDTO);
Task<UserDTO> Authenticate(string UserName, string Password);
Task<UserDTO> AuthenticateNFC(string NFCCode);
Task<RoleDTO> GetRoleAsync(int Id);
Task<List<RoleDTO>> GetAllRoleAsync();
Task<bool> DeleteRoleAsync(int Id);
Task<RoleDTO> UpdateRoleAsync(RoleDTO roleDTO);
Task<UserRoleDTO> GetUserRoleAsync(int Id);
+17 -8
View File
@@ -19,16 +19,13 @@ using Microsoft.AspNetCore.Identity;
namespace WorkFlowCheck.BL.Services
{
public class UserService : IUserService
public class UserService : BaseService, IUserService
{
private AppDbContext _dbContext;
private IMapper _mapper;
private IConfiguration _configuration;
public UserService(AppDbContext dbContext, IMapper mapper, IConfiguration configuration)
public UserService(AppDbContext dbContext, IMapper mapper, IConfiguration configuration) : base(dbContext, mapper)
{
_dbContext = dbContext;
_mapper = mapper;
_configuration = configuration;
}
@@ -76,6 +73,10 @@ namespace WorkFlowCheck.BL.Services
}
return retVal;
}
public async Task<bool> DeleteUserAsync(int id)
{
return await DeleteEntityByIdAsync<User>(id);
}
public async Task<UserDTO> Authenticate(string userName, string password)
{
var retVal = new UserDTO() { RoleDTO = new List<RoleDTO>() };
@@ -199,12 +200,12 @@ namespace WorkFlowCheck.BL.Services
user.LastName = userDTO.LastName;
user.Email = userDTO.Email;
user.NFCActive = userDTO.NFCActive;
user.NFCCode = userDTO.NFCCode;
user.NFCCode = userDTO.NFCCode;
user.JwtToken = "";
user.Token2FA = "";
user.IsDeleted = false;
user.Active = userDTO.Active;
user.PasswordHash = PasswordHasher.HashPassword(userDTO.Password);
@@ -275,6 +276,10 @@ namespace WorkFlowCheck.BL.Services
}
return retVal;
}
public async Task<bool> DeleteRoleAsync(int id)
{
return await DeleteEntityByIdAsync<Role>(id);
}
public async Task<RoleDTO> UpdateRoleAsync(RoleDTO roleDTO)
{
var retVal = new RoleDTO();
@@ -291,6 +296,8 @@ namespace WorkFlowCheck.BL.Services
role.IsAdmin = roleDTO.IsAdmin;
role.CanDownloadAPK = roleDTO.CanDownloadAPK;
role.CanEnableBlocked = roleDTO.CanEnableBlocked;
role.CanUseWebAdmin = roleDTO.CanUseWebAdmin;
role.CanUseMobilApp = roleDTO.CanUseMobilApp;
_dbContext.Roles.Add(role);
await _dbContext.SaveChangesAsync();
@@ -310,6 +317,8 @@ namespace WorkFlowCheck.BL.Services
role.IsAdmin = roleDTO.IsAdmin;
role.CanDownloadAPK = roleDTO.CanDownloadAPK;
role.CanEnableBlocked = roleDTO.CanEnableBlocked;
role.CanUseWebAdmin = roleDTO.CanUseWebAdmin;
role.CanUseMobilApp = roleDTO.CanUseMobilApp;
await _dbContext.SaveChangesAsync();
retVal = _mapper.Map<RoleDTO>(role);