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,12 +5,12 @@ namespace Core.Thalos.Application.UseCases.Modules.Input
{
public class ChangeModuleStatusRequest : 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.Modules.Input
{
public class DeleteModuleRequest : Notificator, ICommand
{
public string _Id { get; set; }
public bool Validate()
{
return _Id != null;
}
}
}

View File

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

View File

@@ -5,7 +5,7 @@ namespace Core.Thalos.Application.UseCases.Modules.Input
{
public class UpdateModuleRequest : 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; }
public string? Icon { get; set; }
@@ -14,7 +14,7 @@ namespace Core.Thalos.Application.UseCases.Modules.Input
public ApplicationsEnum? Application { get; set; } = null!;
public bool Validate()
{
return Id != null;
return _Id != null;
}
}
}

View File

@@ -15,6 +15,7 @@ namespace Core.Thalos.Application.UseCases.Modules
IComponentHandler<GetAllModulesByListRequest>,
IComponentHandler<UpdateModuleRequest>,
IComponentHandler<GetModuleRequest>,
IComponentHandler<DeleteModuleRequest>,
IComponentHandler<CreateModuleRequest>
{
private readonly IModulePort _port;
@@ -46,7 +47,29 @@ namespace Core.Thalos.Application.UseCases.Modules
{
ArgumentNullException.ThrowIfNull(command);
var result = await _thalosDALService.GetModuleByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
var result = await _thalosDALService.GetModuleByIdAsync(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(DeleteModuleRequest command, CancellationToken cancellationToken = default)
{
try
{
ArgumentNullException.ThrowIfNull(command);
var result = await _thalosDALService.DeleteModuleAsync(command._Id, cancellationToken).ConfigureAwait(false);
if (result == null)
{
@@ -120,7 +143,7 @@ namespace Core.Thalos.Application.UseCases.Modules
return;
}
var result = await _thalosDALService.ChangeStatusModuleAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
var result = await _thalosDALService.ChangeStatusModuleAsync(command._Id, command.Status, cancellationToken).ConfigureAwait(false);
if (result == null)
{
@@ -188,7 +211,7 @@ namespace Core.Thalos.Application.UseCases.Modules
var request = new ModuleAdapter
{
Id = command.Id,
_Id = command._Id,
Name = command.Name,
Description = command.Description,
Application = command.Application,
@@ -197,7 +220,7 @@ namespace Core.Thalos.Application.UseCases.Modules
Icon = command.Icon
};
string id = command.Id;
string id = command._Id;
var result = await _thalosDALService.UpdateModuleAsync(request, id, cancellationToken).ConfigureAwait(false);

View File

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