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.Users.Input
{
public class ChangeUserStatusRequest : 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.Users.Input
{
public class DeleteUserRequest : Notificator, ICommand
{
public string _Id { get; set; }
public bool Validate()
{
return _Id != null;
}
}
}

View File

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

View File

@@ -4,7 +4,7 @@ namespace Core.Thalos.Application.UseCases.Users.Input
{
public class UpdateUserRequest : Notificator, ICommand
{
public string Id { get; set; } = null!;
public string _Id { get; set; } = null!;
public string Email { get; set; } = null!;
public string Name { get; set; } = null!;
public string? MiddleName { get; set; }

View File

@@ -12,6 +12,7 @@ namespace Core.Thalos.Application.UseCases.Users
IComponentHandler<ChangeUserStatusRequest>,
IComponentHandler<GetAllUsersRequest>,
IComponentHandler<UpdateUserRequest>,
IComponentHandler<DeleteUserRequest>,
IComponentHandler<GetUserRequest>,
IComponentHandler<GetUserByEmailRequest>,
IComponentHandler<CreateUserRequest>,
@@ -46,7 +47,29 @@ namespace Core.Thalos.Application.UseCases.Users
{
ArgumentNullException.ThrowIfNull(command);
var result = await _thalosDALService.GetUserByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
var result = await _thalosDALService.GetUserByIdAsync(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(DeleteUserRequest command, CancellationToken cancellationToken = default)
{
try
{
ArgumentNullException.ThrowIfNull(command);
var result = await _thalosDALService.DeleteUserAsync(command._Id, cancellationToken).ConfigureAwait(false);
if (result == null)
{
@@ -138,7 +161,7 @@ namespace Core.Thalos.Application.UseCases.Users
return;
}
var result = await _thalosDALService.ChangeUserStatusAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
var result = await _thalosDALService.ChangeUserStatusAsync(command._Id, command.Status, cancellationToken).ConfigureAwait(false);
if (result == null)
{
@@ -205,7 +228,7 @@ namespace Core.Thalos.Application.UseCases.Users
var request = new UserAdapter
{
Id = command.Id,
_Id = command._Id,
Email = command.Email,
Name = command.Name,
MiddleName = command.MiddleName,
@@ -213,7 +236,7 @@ namespace Core.Thalos.Application.UseCases.Users
RoleId = command.RoleId,
};
var result = await _thalosDALService.UpdateUserAsync(request, request.Id, cancellationToken).ConfigureAwait(false);
var result = await _thalosDALService.UpdateUserAsync(request, request._Id, cancellationToken).ConfigureAwait(false);
if (result == null)
{

View File

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

View File

@@ -10,7 +10,7 @@ namespace Core.Thalos.Application.UseCases.Users.Validator
RuleFor(i => i.Email).NotEmpty().NotNull().OverridePropertyName(x => x.Email).WithName("User Email").WithMessage("Email is Obligatory.");
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("User Name").WithMessage("User Name is Obligatory.");
RuleFor(i => i.LastName).NotEmpty().NotNull().OverridePropertyName(x => x.LastName).WithName("User LastName").WithMessage("User LastName is Obligatory.");
RuleFor(i => i.RoleId).NotEmpty().NotNull().OverridePropertyName(x => x.RoleId).WithName("Role Id").WithMessage("Role Id is Obligatory.");
RuleFor(i => i.RoleId).NotEmpty().NotNull().OverridePropertyName(x => x.RoleId).WithName("RoleId").WithMessage("RoleId is Obligatory.");
RuleFor(i => i.Companies).NotEmpty().NotNull().OverridePropertyName(x => x.Companies).WithName("Companies").WithMessage("Companies is Obligatory.");
}
}

View File

@@ -7,10 +7,10 @@ namespace Core.Thalos.Application.UseCases.Users.Validator
{
public UpdateUserValidator()
{
RuleFor(i => i.Email).NotEmpty().NotNull().OverridePropertyName(x => x.Email).WithName("User Email").WithMessage("Email is Obligatory.");
RuleFor(i => i.Email).NotEmpty().NotNull().OverridePropertyName(x => x.Email).WithName("User Email").WithMessage("User Email is Obligatory.");
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("User Name").WithMessage("User Name is Obligatory.");
RuleFor(i => i.LastName).NotEmpty().NotNull().OverridePropertyName(x => x.LastName).WithName("User LastName").WithMessage("User LastName is Obligatory.");
RuleFor(i => i.RoleId).NotEmpty().NotNull().OverridePropertyName(x => x.RoleId).WithName("Role Id").WithMessage("Role Id is Obligatory.");
RuleFor(i => i.RoleId).NotEmpty().NotNull().OverridePropertyName(x => x.RoleId).WithName("RoleId").WithMessage("RoleId is Obligatory.");
RuleFor(i => i.Companies).NotEmpty().NotNull().OverridePropertyName(x => x.Companies).WithName("Companies").WithMessage("Companies is Obligatory.");
}
}