Add tenant services, change id by _id and include delete endpoint for all entities

This commit is contained in:
Sergio Matias Urquin
2025-08-07 18:27:06 -06:00
parent f3d63ca0e3
commit 296aff13fe
47 changed files with 1183 additions and 118 deletions

View File

@@ -5,11 +5,11 @@ namespace Core.Thalos.Application.UseCases.Roles.Input
{
public class ChangeRoleStatusRequest : Notificator, ICommand
{
public string Id { get; set; }
public string _Id { get; set; }
public StatusEnum Status { get; set; }
public bool Validate()
{
return Id != null;
return _Id != null;
}
}
}

View File

@@ -0,0 +1,13 @@
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Roles.Input
{
public class DeleteRoleRequest : Notificator, ICommand
{
public string _Id { get; set; }
public bool Validate()
{
return _Id != null;
}
}
}

View File

@@ -4,10 +4,10 @@ namespace Core.Thalos.Application.UseCases.Roles.Input
{
public class GetRoleRequest : Notificator, ICommand
{
public string Id { get; set; }
public string _Id { get; set; }
public bool Validate()
{
return Id != null;
return _Id != null;
}
}
}

View File

@@ -6,7 +6,7 @@ namespace Core.Thalos.Application.UseCases.Roles.Input
{
public class UpdateRoleRequest : Notificator, ICommand
{
public string Id { get; set; } = null!;
public string _Id { get; set; } = null!;
public string Name { get; set; } = null!;
public string? Description { get; set; }
@@ -18,7 +18,7 @@ namespace Core.Thalos.Application.UseCases.Roles.Input
public bool Validate()
{
return Id != null;
return _Id != null;
}
}
}

View File

@@ -15,6 +15,7 @@ namespace Core.Thalos.Application.UseCases.Role
IComponentHandler<UpdateRoleRequest>,
IComponentHandler<CreateRoleRequest>,
IComponentHandler<GetRoleRequest>,
IComponentHandler<DeleteRoleRequest>,
IComponentHandler<AddApplicationToRoleRequest>,
IComponentHandler<RemoveApplicationFromRoleRequest>
@@ -45,7 +46,29 @@ namespace Core.Thalos.Application.UseCases.Role
{
ArgumentNullException.ThrowIfNull(command);
var result = await _thalosDALService.GetRoleByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
var result = await _thalosDALService.GetRoleByIdAsync(command._Id, cancellationToken).ConfigureAwait(false);
if (result == null)
{
_port.NoContentSuccess();
return;
}
_port.Success(result);
}
catch (Exception ex)
{
ApiResponseHelper.EvaluatePort(ex, _port);
}
}
public async ValueTask ExecuteAsync(DeleteRoleRequest command, CancellationToken cancellationToken = default)
{
try
{
ArgumentNullException.ThrowIfNull(command);
var result = await _thalosDALService.DeleteRoleAsync(command._Id, cancellationToken).ConfigureAwait(false);
if (result == null)
{
@@ -93,7 +116,7 @@ namespace Core.Thalos.Application.UseCases.Role
return;
}
var result = await _thalosDALService.ChangeRoleStatusAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
var result = await _thalosDALService.ChangeRoleStatusAsync(command._Id, command.Status, cancellationToken).ConfigureAwait(false);
if (result == null)
{
@@ -161,7 +184,7 @@ namespace Core.Thalos.Application.UseCases.Role
var request = new RoleAdapter
{
Id = command.Id,
_Id = command._Id,
Name = command.Name,
Description = command.Description,
Applications = command.Applications,
@@ -169,7 +192,7 @@ namespace Core.Thalos.Application.UseCases.Role
Permissions = command.Permissions
};
string id = command.Id;
string id = command._Id;
var result = await _thalosDALService.UpdateRoleAsync(request, id, cancellationToken).ConfigureAwait(false);

View File

@@ -7,7 +7,7 @@ namespace Core.Thalos.Application.UseCases.Roles.Validator
{
public ChangeRoleStatusValidator()
{
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Role ID").WithMessage("Role ID is Obligatory.");
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("Role ID").WithMessage("Role ID is Obligatory.");
RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory.");
}