Compare commits
	
		
			4 Commits
		
	
	
		
			f3d63ca0e3
			...
			feature/ad
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 39341a6640 | ||
| 5d637e9d4f | |||
|   | 2d1dfb19ed | ||
|   | 296aff13fe | 
| @@ -5,12 +5,12 @@ namespace Core.Thalos.Application.UseCases.Modules.Input | |||||||
| { | { | ||||||
|     public class ChangeModuleStatusRequest : Notificator, ICommand |     public class ChangeModuleStatusRequest : Notificator, ICommand | ||||||
|     { |     { | ||||||
|         public string Id { get; set; } |         public string _Id { get; set; } | ||||||
|         public StatusEnum Status { get; set; } |         public StatusEnum Status { get; set; } | ||||||
|  |  | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return Id != null; |             return _Id != null; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -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; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -4,10 +4,10 @@ namespace Core.Thalos.Application.UseCases.Modules.Input | |||||||
| { | { | ||||||
|     public class GetModuleRequest : Notificator, ICommand |     public class GetModuleRequest : Notificator, ICommand | ||||||
|     { |     { | ||||||
|         public string Id { get; set; } |         public string _Id { get; set; } | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return Id != null; |             return _Id != null; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ namespace Core.Thalos.Application.UseCases.Modules.Input | |||||||
| { | { | ||||||
|     public class UpdateModuleRequest : Notificator, ICommand |     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 Name { get; set; } = null!; | ||||||
|         public string? Description { get; set; } |         public string? Description { get; set; } | ||||||
|         public string? Icon { 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 ApplicationsEnum? Application { get; set; } = null!; | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return Id != null; |             return _Id != null; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ namespace Core.Thalos.Application.UseCases.Modules | |||||||
|         IComponentHandler<GetAllModulesByListRequest>, |         IComponentHandler<GetAllModulesByListRequest>, | ||||||
|         IComponentHandler<UpdateModuleRequest>, |         IComponentHandler<UpdateModuleRequest>, | ||||||
|         IComponentHandler<GetModuleRequest>, |         IComponentHandler<GetModuleRequest>, | ||||||
|  |         IComponentHandler<DeleteModuleRequest>, | ||||||
|         IComponentHandler<CreateModuleRequest> |         IComponentHandler<CreateModuleRequest> | ||||||
|     { |     { | ||||||
|         private readonly IModulePort _port; |         private readonly IModulePort _port; | ||||||
| @@ -46,7 +47,29 @@ namespace Core.Thalos.Application.UseCases.Modules | |||||||
|             { |             { | ||||||
|                 ArgumentNullException.ThrowIfNull(command); |                 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) |                 if (result == null) | ||||||
|                 { |                 { | ||||||
| @@ -120,7 +143,7 @@ namespace Core.Thalos.Application.UseCases.Modules | |||||||
|                     return; |                     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) |                 if (result == null) | ||||||
|                 { |                 { | ||||||
| @@ -188,7 +211,7 @@ namespace Core.Thalos.Application.UseCases.Modules | |||||||
|  |  | ||||||
|                 var request = new ModuleAdapter |                 var request = new ModuleAdapter | ||||||
|                 { |                 { | ||||||
|                     Id = command.Id, |                     _Id = command._Id, | ||||||
|                     Name = command.Name, |                     Name = command.Name, | ||||||
|                     Description = command.Description, |                     Description = command.Description, | ||||||
|                     Application = command.Application, |                     Application = command.Application, | ||||||
| @@ -197,7 +220,7 @@ namespace Core.Thalos.Application.UseCases.Modules | |||||||
|                     Icon = command.Icon |                     Icon = command.Icon | ||||||
|                 }; |                 }; | ||||||
|  |  | ||||||
|                 string id = command.Id; |                 string id = command._Id; | ||||||
|  |  | ||||||
|                 var result = await _thalosDALService.UpdateModuleAsync(request, id, cancellationToken).ConfigureAwait(false); |                 var result = await _thalosDALService.UpdateModuleAsync(request, id, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ namespace Core.Thalos.Application.UseCases.Modules.Validator | |||||||
|     { |     { | ||||||
|         public ChangeModuleStatusValidator() |         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."); |             RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory."); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -5,12 +5,12 @@ namespace Core.Thalos.Application.UseCases.Permissions.Input | |||||||
| { | { | ||||||
|     public class ChangePermissionStatusRequest : Notificator, ICommand |     public class ChangePermissionStatusRequest : Notificator, ICommand | ||||||
|     { |     { | ||||||
|         public string Id { get; set; } |         public string _Id { get; set; } | ||||||
|         public StatusEnum Status { get; set; } |         public StatusEnum Status { get; set; } | ||||||
|  |  | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return Id != null; |             return _Id != null; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -0,0 +1,13 @@ | |||||||
|  | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Application.UseCases.Permissions.Input | ||||||
|  | { | ||||||
|  |     public class DeletePermissionRequest : Notificator, ICommand | ||||||
|  |     { | ||||||
|  |         public string _Id { get; set; } | ||||||
|  |         public bool Validate() | ||||||
|  |         { | ||||||
|  |             return _Id != null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -4,10 +4,10 @@ namespace Core.Thalos.Application.UseCases.Permissions.Input | |||||||
| { | { | ||||||
|     public class GetPermissionRequest : Notificator, ICommand |     public class GetPermissionRequest : Notificator, ICommand | ||||||
|     { |     { | ||||||
|         public string Id { get; set; } |         public string _Id { get; set; } | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return Id != null; |             return _Id != null; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,14 +5,14 @@ namespace Core.Thalos.Application.UseCases.Permissions.Input | |||||||
| { | { | ||||||
|     public class UpdatePermissionRequest : Notificator, ICommand |     public class UpdatePermissionRequest : Notificator, ICommand | ||||||
|     { |     { | ||||||
|         public string Id { get; set; } = null!; |         public string _Id { get; set; } = null!; | ||||||
|         public string Name { get; set; } = null!; |         public string Name { get; set; } = null!; | ||||||
|         public string? Description { get; set; } |         public string? Description { get; set; } | ||||||
|         public AccessLevelEnum? AccessLevel { get; set; } = null!; |         public AccessLevelEnum? AccessLevel { get; set; } = null!; | ||||||
|         public Blueprint.Mongo.StatusEnum Status { get; set; } |         public Blueprint.Mongo.StatusEnum Status { get; set; } | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return Id != null; |             return _Id != null; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ namespace Core.Thalos.Application.UseCases.Permissions | |||||||
|         IComponentHandler<GetAllPermissionsByListRequest>, |         IComponentHandler<GetAllPermissionsByListRequest>, | ||||||
|         IComponentHandler<UpdatePermissionRequest>, |         IComponentHandler<UpdatePermissionRequest>, | ||||||
|         IComponentHandler<GetPermissionRequest>, |         IComponentHandler<GetPermissionRequest>, | ||||||
|  |         IComponentHandler<DeletePermissionRequest>, | ||||||
|         IComponentHandler<CreatePermissionRequest> |         IComponentHandler<CreatePermissionRequest> | ||||||
|     { |     { | ||||||
|         private readonly IPermissionPort _port; |         private readonly IPermissionPort _port; | ||||||
| @@ -43,7 +44,29 @@ namespace Core.Thalos.Application.UseCases.Permissions | |||||||
|             { |             { | ||||||
|                 ArgumentNullException.ThrowIfNull(command); |                 ArgumentNullException.ThrowIfNull(command); | ||||||
|  |  | ||||||
|                 var result = await _thalosDALService.GetPermissionByIdAsync(command.Id, cancellationToken).ConfigureAwait(false); |                 var result = await _thalosDALService.GetPermissionByIdAsync(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(DeletePermissionRequest command, CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 ArgumentNullException.ThrowIfNull(command); | ||||||
|  |  | ||||||
|  |                 var result = await _thalosDALService.DeletePermissionAsync(command._Id, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|                 if (result == null) |                 if (result == null) | ||||||
|                 { |                 { | ||||||
| @@ -111,7 +134,7 @@ namespace Core.Thalos.Application.UseCases.Permissions | |||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 var result = await _thalosDALService.ChangeStatusPermissionAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false); |                 var result = await _thalosDALService.ChangeStatusPermissionAsync(command._Id, command.Status, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|                 if (result == null) |                 if (result == null) | ||||||
|                 { |                 { | ||||||
| @@ -176,13 +199,13 @@ namespace Core.Thalos.Application.UseCases.Permissions | |||||||
|  |  | ||||||
|                 var request = new PermissionAdapter |                 var request = new PermissionAdapter | ||||||
|                 { |                 { | ||||||
|                     Id = command.Id, |                     _Id = command._Id, | ||||||
|                     Name = command.Name, |                     Name = command.Name, | ||||||
|                     Description = command.Description, |                     Description = command.Description, | ||||||
|                     AccessLevel = command.AccessLevel |                     AccessLevel = command.AccessLevel | ||||||
|                 }; |                 }; | ||||||
|  |  | ||||||
|                 string id = command.Id; |                 string id = command._Id; | ||||||
|  |  | ||||||
|                 var result = await _thalosDALService.UpdatePermissionAsync(request, id, cancellationToken).ConfigureAwait(false); |                 var result = await _thalosDALService.UpdatePermissionAsync(request, id, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ namespace Core.Thalos.Application.UseCases.Permissions.Validator | |||||||
|     { |     { | ||||||
|         public ChangePermissionStatusValidator() |         public ChangePermissionStatusValidator() | ||||||
|         { |         { | ||||||
|             RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Permission ID").WithMessage("Permission ID is Obligatory."); |             RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("Permission ID").WithMessage("Permission ID is Obligatory."); | ||||||
|             RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory."); |             RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory."); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,11 +5,11 @@ namespace Core.Thalos.Application.UseCases.Roles.Input | |||||||
| { | { | ||||||
|     public class ChangeRoleStatusRequest : Notificator, ICommand |     public class ChangeRoleStatusRequest : Notificator, ICommand | ||||||
|     { |     { | ||||||
|         public string Id { get; set; } |         public string _Id { get; set; } | ||||||
|         public StatusEnum Status { get; set; } |         public StatusEnum Status { get; set; } | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return Id != null; |             return _Id != null; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -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; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -4,10 +4,10 @@ namespace Core.Thalos.Application.UseCases.Roles.Input | |||||||
| { | { | ||||||
|     public class GetRoleRequest : Notificator, ICommand |     public class GetRoleRequest : Notificator, ICommand | ||||||
|     { |     { | ||||||
|         public string Id { get; set; } |         public string _Id { get; set; } | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return Id != null; |             return _Id != null; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ namespace Core.Thalos.Application.UseCases.Roles.Input | |||||||
| { | { | ||||||
|     public class UpdateRoleRequest : Notificator, ICommand |     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 Name { get; set; } = null!; | ||||||
|         public string? Description { get; set; } |         public string? Description { get; set; } | ||||||
|  |  | ||||||
| @@ -18,7 +18,7 @@ namespace Core.Thalos.Application.UseCases.Roles.Input | |||||||
|  |  | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return Id != null; |             return _Id != null; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ namespace Core.Thalos.Application.UseCases.Role | |||||||
|         IComponentHandler<UpdateRoleRequest>, |         IComponentHandler<UpdateRoleRequest>, | ||||||
|         IComponentHandler<CreateRoleRequest>, |         IComponentHandler<CreateRoleRequest>, | ||||||
|         IComponentHandler<GetRoleRequest>, |         IComponentHandler<GetRoleRequest>, | ||||||
|  |         IComponentHandler<DeleteRoleRequest>, | ||||||
|         IComponentHandler<AddApplicationToRoleRequest>, |         IComponentHandler<AddApplicationToRoleRequest>, | ||||||
|         IComponentHandler<RemoveApplicationFromRoleRequest> |         IComponentHandler<RemoveApplicationFromRoleRequest> | ||||||
|  |  | ||||||
| @@ -45,7 +46,29 @@ namespace Core.Thalos.Application.UseCases.Role | |||||||
|             { |             { | ||||||
|                 ArgumentNullException.ThrowIfNull(command); |                 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) |                 if (result == null) | ||||||
|                 { |                 { | ||||||
| @@ -93,7 +116,7 @@ namespace Core.Thalos.Application.UseCases.Role | |||||||
|                     return; |                     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) |                 if (result == null) | ||||||
|                 { |                 { | ||||||
| @@ -161,7 +184,7 @@ namespace Core.Thalos.Application.UseCases.Role | |||||||
|  |  | ||||||
|                 var request = new RoleAdapter |                 var request = new RoleAdapter | ||||||
|                 { |                 { | ||||||
|                     Id = command.Id, |                     _Id = command._Id, | ||||||
|                     Name = command.Name, |                     Name = command.Name, | ||||||
|                     Description = command.Description, |                     Description = command.Description, | ||||||
|                     Applications = command.Applications, |                     Applications = command.Applications, | ||||||
| @@ -169,7 +192,7 @@ namespace Core.Thalos.Application.UseCases.Role | |||||||
|                     Permissions = command.Permissions |                     Permissions = command.Permissions | ||||||
|                 }; |                 }; | ||||||
|  |  | ||||||
|                 string id = command.Id; |                 string id = command._Id; | ||||||
|  |  | ||||||
|                 var result = await _thalosDALService.UpdateRoleAsync(request, id, cancellationToken).ConfigureAwait(false); |                 var result = await _thalosDALService.UpdateRoleAsync(request, id, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ namespace Core.Thalos.Application.UseCases.Roles.Validator | |||||||
|     { |     { | ||||||
|         public ChangeRoleStatusValidator() |         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."); |             RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory."); | ||||||
|  |  | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -0,0 +1,19 @@ | |||||||
|  | using Core.Thalos.Application.UseCases.Tenants.Ports; | ||||||
|  | using Core.Thalos.BuildingBlocks; | ||||||
|  | using Lib.Architecture.BuildingBlocks; | ||||||
|  | using Microsoft.AspNetCore.Mvc; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Application.UseCases.Tenants.Adapter | ||||||
|  | { | ||||||
|  |     public class TenantPort : BasePresenter, ITenantPort | ||||||
|  |     { | ||||||
|  |         public void Success(TenantAdapter output) | ||||||
|  |         { | ||||||
|  |             ViewModel = new OkObjectResult(output); | ||||||
|  |         } | ||||||
|  |         public void Success(List<TenantAdapter> output) | ||||||
|  |         { | ||||||
|  |             ViewModel = new OkObjectResult(output); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,16 @@ | |||||||
|  | using Core.Blueprint.Mongo; | ||||||
|  | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Application.UseCases.Tenants.Input | ||||||
|  | { | ||||||
|  |     public class ChangeTenantStatusRequest : Notificator, ICommand | ||||||
|  |     { | ||||||
|  |         public string _Id { get; set; } | ||||||
|  |         public StatusEnum Status { get; set; } | ||||||
|  |  | ||||||
|  |         public bool Validate() | ||||||
|  |         { | ||||||
|  |             return _Id != null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,38 @@ | |||||||
|  | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Application.UseCases.Tenants.Input | ||||||
|  | { | ||||||
|  |     public class CreateTenantRequest : Notificator, ICommand | ||||||
|  |     { | ||||||
|  |         public string Name { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string TaxIdentifier { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string AddressLine1 { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string? AddressLine2 { get; set; } | ||||||
|  |  | ||||||
|  |         public string City { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string State { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string Country { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string PostalCode { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string ContactEmail { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string ContactPhone { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string? Website { get; set; } | ||||||
|  |  | ||||||
|  |         public string? ConnectionString { get; set; } | ||||||
|  |  | ||||||
|  |         public bool Isolated { get; set; } | ||||||
|  |  | ||||||
|  |         public bool Validate() | ||||||
|  |         { | ||||||
|  |             return Name != null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,13 @@ | |||||||
|  | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Application.UseCases.Tenants.Input | ||||||
|  | { | ||||||
|  |     public class DeleteTenantRequest : Notificator, ICommand | ||||||
|  |     { | ||||||
|  |         public string _Id { get; set; } | ||||||
|  |         public bool Validate() | ||||||
|  |         { | ||||||
|  |             return _Id != null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,12 @@ | |||||||
|  | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Application.UseCases.Tenants.Input | ||||||
|  | { | ||||||
|  |     public class GetAllTenantsRequest : ICommand | ||||||
|  |     { | ||||||
|  |         public bool Validate() | ||||||
|  |         { | ||||||
|  |             return true; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,13 @@ | |||||||
|  | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Application.UseCases.Tenants.Input | ||||||
|  | { | ||||||
|  |     public class GetTenantRequest : Notificator, ICommand | ||||||
|  |     { | ||||||
|  |         public string _Id { get; set; } | ||||||
|  |         public bool Validate() | ||||||
|  |         { | ||||||
|  |             return _Id != null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,45 @@ | |||||||
|  | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Application.UseCases.Tenants.Input | ||||||
|  | { | ||||||
|  |     public class UpdateTenantRequest : Notificator, ICommand | ||||||
|  |     { | ||||||
|  |         public string Name { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string TaxIdentifier { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string AddressLine1 { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string? AddressLine2 { get; set; } | ||||||
|  |  | ||||||
|  |         public string City { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string State { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string Country { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string PostalCode { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string ContactEmail { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string ContactPhone { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         public string? Website { get; set; } | ||||||
|  |  | ||||||
|  |         public string? ConnectionString { get; set; } | ||||||
|  |  | ||||||
|  |         public bool Isolated { get; set; } | ||||||
|  |         public string _Id { get; set; } = null!; | ||||||
|  |         public string Id { get; init; } = null!; | ||||||
|  |         public DateTime CreatedAt { get; set; } | ||||||
|  |         public string? CreatedBy { get; set; } | ||||||
|  |         public DateTime? UpdatedAt { get; set; } | ||||||
|  |         public string? UpdatedBy { get; set; } | ||||||
|  |  | ||||||
|  |         public Blueprint.Mongo.StatusEnum Status { get; set; } | ||||||
|  |         public bool Validate() | ||||||
|  |         { | ||||||
|  |             return _Id != null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,14 @@ | |||||||
|  | using Core.Thalos.BuildingBlocks; | ||||||
|  | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Application.UseCases.Tenants.Ports | ||||||
|  | { | ||||||
|  |     public interface ITenantPort : IBasePort, | ||||||
|  |         ICommandSuccessPort<TenantAdapter>, | ||||||
|  |         ICommandSuccessPort<List<TenantAdapter>>, | ||||||
|  |         INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort, | ||||||
|  |         INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort, | ||||||
|  |         IBadRequestPort | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										223
									
								
								Core.Thalos.Application/UseCases/Tenants/TenantHandler.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										223
									
								
								Core.Thalos.Application/UseCases/Tenants/TenantHandler.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,223 @@ | |||||||
|  | using Core.Thalos.Application.UseCases.Tenants.Input; | ||||||
|  | using Core.Thalos.Application.UseCases.Tenants.Ports; | ||||||
|  | using Core.Thalos.BuildingBlocks; | ||||||
|  | using Core.Thalos.External.Clients; | ||||||
|  | using FluentValidation; | ||||||
|  | using Lib.Architecture.BuildingBlocks; | ||||||
|  | using Lib.Architecture.BuildingBlocks.Helpers; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Application.UseCases.Tenants | ||||||
|  | { | ||||||
|  |     public class TenantHandler : | ||||||
|  |         IComponentHandler<ChangeTenantStatusRequest>, | ||||||
|  |         IComponentHandler<GetAllTenantsRequest>, | ||||||
|  |         IComponentHandler<UpdateTenantRequest>, | ||||||
|  |         IComponentHandler<GetTenantRequest>, | ||||||
|  |         IComponentHandler<DeleteTenantRequest>, | ||||||
|  |         IComponentHandler<CreateTenantRequest> | ||||||
|  |     { | ||||||
|  |         private readonly ITenantPort _port; | ||||||
|  |         private readonly IValidator<ChangeTenantStatusRequest> _changeTenantStatusValidator; | ||||||
|  |         private readonly IValidator<CreateTenantRequest> _registerTenantValidator; | ||||||
|  |         private readonly IValidator<UpdateTenantRequest> _updateTenantValidator; | ||||||
|  |         private readonly IThalosServiceClient _thalosDALService; | ||||||
|  |  | ||||||
|  |         public TenantHandler( | ||||||
|  |             ITenantPort port, | ||||||
|  |             IValidator<ChangeTenantStatusRequest> changeTenantStatusValidator, | ||||||
|  |             IValidator<CreateTenantRequest> registerTenantValidator, | ||||||
|  |             IValidator<UpdateTenantRequest> updateTenantValidator, | ||||||
|  |             IThalosServiceClient thalosDALService) | ||||||
|  |         { | ||||||
|  |             _port = port ?? throw new ArgumentNullException(nameof(port)); | ||||||
|  |             _changeTenantStatusValidator = changeTenantStatusValidator ?? throw new ArgumentNullException(nameof(changeTenantStatusValidator)); | ||||||
|  |             _registerTenantValidator = registerTenantValidator ?? throw new ArgumentNullException(nameof(registerTenantValidator)); | ||||||
|  |             _updateTenantValidator = updateTenantValidator ?? throw new ArgumentNullException(nameof(updateTenantValidator)); | ||||||
|  |             _thalosDALService = thalosDALService ?? throw new ArgumentNullException(nameof(thalosDALService)); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public async ValueTask ExecuteAsync(GetTenantRequest command, CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 ArgumentNullException.ThrowIfNull(command); | ||||||
|  |  | ||||||
|  |                 var result = await _thalosDALService.GetTenantByIdAsync(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(DeleteTenantRequest command, CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 ArgumentNullException.ThrowIfNull(command); | ||||||
|  |  | ||||||
|  |                 var result = await _thalosDALService.DeleteTenantAsync(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(GetAllTenantsRequest command, CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 ArgumentNullException.ThrowIfNull(command); | ||||||
|  |  | ||||||
|  |                 var _result = await _thalosDALService.GetAllTenantsAsync().ConfigureAwait(false); | ||||||
|  |                 if (!_result.Any()) | ||||||
|  |                 { | ||||||
|  |                     _port.NoContentSuccess(); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |                 _port.Success(_result.ToList()); | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 ApiResponseHelper.EvaluatePort(ex, _port); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         public async ValueTask ExecuteAsync(ChangeTenantStatusRequest command, CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 ArgumentNullException.ThrowIfNull(command); | ||||||
|  |  | ||||||
|  |                 if (!command.IsValid(_changeTenantStatusValidator)) | ||||||
|  |                 { | ||||||
|  |                     _port.ValidationErrors(command.Notifications); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 var result = await _thalosDALService.ChangeStatusTenantAsync(command._Id, command.Status, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|  |                 if (result == null) | ||||||
|  |                 { | ||||||
|  |                     _port.NoContentSuccess(); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 _port.Success(result); | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 ApiResponseHelper.EvaluatePort(ex, _port); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public async ValueTask ExecuteAsync(CreateTenantRequest command, CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 ArgumentNullException.ThrowIfNull(command); | ||||||
|  |  | ||||||
|  |                 if (!command.IsValid(_registerTenantValidator)) | ||||||
|  |                 { | ||||||
|  |                     _port.ValidationErrors(command.Notifications); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 var request = new TenantRequest | ||||||
|  |                 { | ||||||
|  |                     Name = command.Name, | ||||||
|  |                     AddressLine1 = command.AddressLine1, | ||||||
|  |                     AddressLine2 = command.AddressLine2, | ||||||
|  |                     TaxIdentifier = command.TaxIdentifier, | ||||||
|  |                     City = command.City, | ||||||
|  |                     State = command.State, | ||||||
|  |                     Country = command.Country, | ||||||
|  |                     PostalCode = command.PostalCode, | ||||||
|  |                     ContactEmail = command.ContactEmail, | ||||||
|  |                     ContactPhone = command.ContactPhone, | ||||||
|  |                     Website = command.Website, | ||||||
|  |                     ConnectionString = command.ConnectionString, | ||||||
|  |                     Isolated = command.Isolated | ||||||
|  |                 }; | ||||||
|  |  | ||||||
|  |                 var result = await _thalosDALService.CreateTenantAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|  |                 if (result == null) | ||||||
|  |                 { | ||||||
|  |                     _port.NoContentSuccess(); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 _port.Success(result); | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 ApiResponseHelper.EvaluatePort(ex, _port); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public async ValueTask ExecuteAsync(UpdateTenantRequest command, CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 ArgumentNullException.ThrowIfNull(command); | ||||||
|  |  | ||||||
|  |                 if (!command.IsValid(_updateTenantValidator)) | ||||||
|  |                 { | ||||||
|  |                     _port.ValidationErrors(command.Notifications); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 var request = new TenantAdapter | ||||||
|  |                 { | ||||||
|  |                     _Id = command._Id, | ||||||
|  |                     Name = command.Name, | ||||||
|  |                     AddressLine1 = command.AddressLine1, | ||||||
|  |                     AddressLine2 = command.AddressLine2, | ||||||
|  |                     TaxIdentifier = command.TaxIdentifier, | ||||||
|  |                     City = command.City, | ||||||
|  |                     State = command.State, | ||||||
|  |                     Country = command.Country, | ||||||
|  |                     PostalCode = command.PostalCode, | ||||||
|  |                     ContactEmail = command.ContactEmail, | ||||||
|  |                     ContactPhone = command.ContactPhone, | ||||||
|  |                     Website = command.Website, | ||||||
|  |                     ConnectionString = command.ConnectionString, | ||||||
|  |                     Isolated = command.Isolated | ||||||
|  |                 }; | ||||||
|  |  | ||||||
|  |                 string id = command._Id; | ||||||
|  |  | ||||||
|  |                 var result = await _thalosDALService.UpdateTenantAsync(request, id, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|  |                 if (result == null) | ||||||
|  |                 { | ||||||
|  |                     _port.NoContentSuccess(); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 _port.Success(result); | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 ApiResponseHelper.EvaluatePort(ex, _port); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,15 @@ | |||||||
|  | using Core.Thalos.Application.UseCases.Tenants.Input; | ||||||
|  | using FluentValidation; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Application.UseCases.Tenants.Validator | ||||||
|  | { | ||||||
|  |     public class ChangeTenantStatusValidator : AbstractValidator<ChangeTenantStatusRequest> | ||||||
|  |     { | ||||||
|  |         public ChangeTenantStatusValidator() | ||||||
|  |         { | ||||||
|  |             RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("Tenant ID").WithMessage("Tenant ID is Obligatory."); | ||||||
|  |             RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory."); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,74 @@ | |||||||
|  | using Core.Thalos.Application.UseCases.Tenants.Input; | ||||||
|  | using FluentValidation; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Application.UseCases.Tenants.Validator | ||||||
|  | { | ||||||
|  |     public class CreateTenantValidator : AbstractValidator<CreateTenantRequest> | ||||||
|  |     { | ||||||
|  |         public CreateTenantValidator() | ||||||
|  |         { | ||||||
|  |             RuleFor(i => i.Name) | ||||||
|  |                 .NotEmpty() | ||||||
|  |                 .NotNull() | ||||||
|  |                 .OverridePropertyName(x => x.Name) | ||||||
|  |                 .WithName("Tenant Name") | ||||||
|  |                 .WithMessage("Tenant Name is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.TaxIdentifier) | ||||||
|  |                 .NotEmpty() | ||||||
|  |                 .NotNull() | ||||||
|  |                 .OverridePropertyName(x => x.TaxIdentifier) | ||||||
|  |                 .WithName("Tax Identifier") | ||||||
|  |                 .WithMessage("Tax Identifier is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.AddressLine1) | ||||||
|  |                 .NotEmpty() | ||||||
|  |                 .NotNull() | ||||||
|  |                 .OverridePropertyName(x => x.AddressLine1) | ||||||
|  |                 .WithName("Address Line 1") | ||||||
|  |                 .WithMessage("Address Line 1 is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.City) | ||||||
|  |                 .NotEmpty() | ||||||
|  |                 .NotNull() | ||||||
|  |                 .OverridePropertyName(x => x.City) | ||||||
|  |                 .WithName("City") | ||||||
|  |                 .WithMessage("City is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.State) | ||||||
|  |                 .NotEmpty() | ||||||
|  |                 .NotNull() | ||||||
|  |                 .OverridePropertyName(x => x.State) | ||||||
|  |                 .WithName("State") | ||||||
|  |                 .WithMessage("State is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.Country) | ||||||
|  |                 .NotEmpty() | ||||||
|  |                 .NotNull() | ||||||
|  |                 .OverridePropertyName(x => x.Country) | ||||||
|  |                 .WithName("Country") | ||||||
|  |                 .WithMessage("Country is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.PostalCode) | ||||||
|  |                 .NotEmpty() | ||||||
|  |                 .NotNull() | ||||||
|  |                 .OverridePropertyName(x => x.PostalCode) | ||||||
|  |                 .WithName("Postal Code") | ||||||
|  |                 .WithMessage("Postal Code is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.ContactEmail) | ||||||
|  |                 .NotEmpty() | ||||||
|  |                 .NotNull() | ||||||
|  |                 .OverridePropertyName(x => x.ContactEmail) | ||||||
|  |                 .WithName("Contact Email") | ||||||
|  |                 .WithMessage("Contact Email is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.ContactPhone) | ||||||
|  |                 .NotEmpty() | ||||||
|  |                 .NotNull() | ||||||
|  |                 .OverridePropertyName(x => x.ContactPhone) | ||||||
|  |                 .WithName("Contact Phone") | ||||||
|  |                 .WithMessage("Contact Phone is obligatory."); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,66 @@ | |||||||
|  | using Core.Thalos.Application.UseCases.Tenants.Input; | ||||||
|  | using FluentValidation; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Application.UseCases.Tenants.Validator | ||||||
|  | { | ||||||
|  |     public class UpdateTenantValidator : AbstractValidator<UpdateTenantRequest> | ||||||
|  |     { | ||||||
|  |         public UpdateTenantValidator() | ||||||
|  |         { | ||||||
|  |             RuleFor(i => i.Name) | ||||||
|  |                 .NotEmpty().NotNull() | ||||||
|  |                 .WithName("Tenant Name") | ||||||
|  |                 .WithMessage("Tenant Name is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.TaxIdentifier) | ||||||
|  |                 .NotEmpty().NotNull() | ||||||
|  |                 .WithName("Tax Identifier") | ||||||
|  |                 .WithMessage("Tax Identifier is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.AddressLine1) | ||||||
|  |                 .NotEmpty().NotNull() | ||||||
|  |                 .WithName("Address Line 1") | ||||||
|  |                 .WithMessage("Address Line 1 is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.City) | ||||||
|  |                 .NotEmpty().NotNull() | ||||||
|  |                 .WithName("City") | ||||||
|  |                 .WithMessage("City is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.State) | ||||||
|  |                 .NotEmpty().NotNull() | ||||||
|  |                 .WithName("State") | ||||||
|  |                 .WithMessage("State is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.Country) | ||||||
|  |                 .NotEmpty().NotNull() | ||||||
|  |                 .WithName("Country") | ||||||
|  |                 .WithMessage("Country is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.PostalCode) | ||||||
|  |                 .NotEmpty().NotNull() | ||||||
|  |                 .WithName("Postal Code") | ||||||
|  |                 .WithMessage("Postal Code is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.ContactEmail) | ||||||
|  |                 .NotEmpty().NotNull() | ||||||
|  |                 .WithName("Contact Email") | ||||||
|  |                 .WithMessage("Contact Email is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.ContactPhone) | ||||||
|  |                 .NotEmpty().NotNull() | ||||||
|  |                 .WithName("Contact Phone") | ||||||
|  |                 .WithMessage("Contact Phone is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i._Id) | ||||||
|  |                 .NotEmpty().NotNull() | ||||||
|  |                 .WithName("Internal ID") | ||||||
|  |                 .WithMessage("Internal ID is obligatory."); | ||||||
|  |  | ||||||
|  |             RuleFor(i => i.Id) | ||||||
|  |                 .NotEmpty().NotNull() | ||||||
|  |                 .WithName("Tenant ID") | ||||||
|  |                 .WithMessage("Tenant ID is obligatory."); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -5,12 +5,12 @@ namespace Core.Thalos.Application.UseCases.Users.Input | |||||||
| { | { | ||||||
|     public class ChangeUserStatusRequest : Notificator, ICommand |     public class ChangeUserStatusRequest : Notificator, ICommand | ||||||
|     { |     { | ||||||
|         public string Id { get; set; } |         public string _Id { get; set; } | ||||||
|         public StatusEnum Status { get; set; } |         public StatusEnum Status { get; set; } | ||||||
|  |  | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return Id != null; |             return _Id != null; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -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; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -4,10 +4,10 @@ namespace Core.Thalos.Application.UseCases.Users.Input | |||||||
| { | { | ||||||
|     public class GetUserRequest : Notificator, ICommand |     public class GetUserRequest : Notificator, ICommand | ||||||
|     { |     { | ||||||
|         public string Id { get; set; } |         public string _Id { get; set; } | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return Id != null; |             return _Id != null; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ namespace Core.Thalos.Application.UseCases.Users.Input | |||||||
| { | { | ||||||
|     public class UpdateUserRequest : Notificator, ICommand |     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 Email { get; set; } = null!; | ||||||
|         public string Name { get; set; } = null!; |         public string Name { get; set; } = null!; | ||||||
|         public string? MiddleName { get; set; } |         public string? MiddleName { get; set; } | ||||||
|   | |||||||
| @@ -12,6 +12,7 @@ namespace Core.Thalos.Application.UseCases.Users | |||||||
|         IComponentHandler<ChangeUserStatusRequest>, |         IComponentHandler<ChangeUserStatusRequest>, | ||||||
|         IComponentHandler<GetAllUsersRequest>, |         IComponentHandler<GetAllUsersRequest>, | ||||||
|         IComponentHandler<UpdateUserRequest>, |         IComponentHandler<UpdateUserRequest>, | ||||||
|  |         IComponentHandler<DeleteUserRequest>, | ||||||
|         IComponentHandler<GetUserRequest>, |         IComponentHandler<GetUserRequest>, | ||||||
|         IComponentHandler<GetUserByEmailRequest>, |         IComponentHandler<GetUserByEmailRequest>, | ||||||
|         IComponentHandler<CreateUserRequest>, |         IComponentHandler<CreateUserRequest>, | ||||||
| @@ -46,7 +47,29 @@ namespace Core.Thalos.Application.UseCases.Users | |||||||
|             { |             { | ||||||
|                 ArgumentNullException.ThrowIfNull(command); |                 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) |                 if (result == null) | ||||||
|                 { |                 { | ||||||
| @@ -138,7 +161,7 @@ namespace Core.Thalos.Application.UseCases.Users | |||||||
|                     return; |                     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) |                 if (result == null) | ||||||
|                 { |                 { | ||||||
| @@ -205,7 +228,7 @@ namespace Core.Thalos.Application.UseCases.Users | |||||||
|  |  | ||||||
|                 var request = new UserAdapter |                 var request = new UserAdapter | ||||||
|                 { |                 { | ||||||
|                     Id = command.Id, |                     _Id = command._Id, | ||||||
|                     Email = command.Email, |                     Email = command.Email, | ||||||
|                     Name = command.Name, |                     Name = command.Name, | ||||||
|                     MiddleName = command.MiddleName, |                     MiddleName = command.MiddleName, | ||||||
| @@ -213,7 +236,7 @@ namespace Core.Thalos.Application.UseCases.Users | |||||||
|                     RoleId = command.RoleId, |                     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) |                 if (result == null) | ||||||
|                 { |                 { | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ namespace Core.Thalos.Application.UseCases.Users.Validator | |||||||
|     { |     { | ||||||
|         public ChangeUserStatusValidator() |         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."); |             RuleFor(i => i.Status).NotNull().NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory."); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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.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.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.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."); |             RuleFor(i => i.Companies).NotEmpty().NotNull().OverridePropertyName(x => x.Companies).WithName("Companies").WithMessage("Companies is Obligatory."); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -7,10 +7,10 @@ namespace Core.Thalos.Application.UseCases.Users.Validator | |||||||
|     { |     { | ||||||
|         public UpdateUserValidator() |         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.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.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."); |             RuleFor(i => i.Companies).NotEmpty().NotNull().OverridePropertyName(x => x.Companies).WithName("Companies").WithMessage("Companies is Obligatory."); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ namespace Core.Thalos.External.Clients | |||||||
|         Task<IEnumerable<UserAdapter>> GetAllUsersAsync(CancellationToken cancellationToken = default); |         Task<IEnumerable<UserAdapter>> GetAllUsersAsync(CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Get("/v1/User/" + Routes.Id)] |         [Get("/v1/User/" + Routes.Id)] | ||||||
|         Task<UserAdapter> GetUserByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default); |         Task<UserAdapter> GetUserByIdAsync([FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Get("/v1/User/" + Routes.Email)] |         [Get("/v1/User/" + Routes.Email)] | ||||||
|         Task<UserAdapter> GetUserByEmailAsync([FromRoute] string email, CancellationToken cancellationToken = default); |         Task<UserAdapter> GetUserByEmailAsync([FromRoute] string email, CancellationToken cancellationToken = default); | ||||||
| @@ -23,7 +23,10 @@ namespace Core.Thalos.External.Clients | |||||||
|         Task<UserAdapter> CreateUserAsync([FromBody] UserRequest newUser, [FromRoute] bool sendInvitation, CancellationToken cancellationToken = default); |         Task<UserAdapter> CreateUserAsync([FromBody] UserRequest newUser, [FromRoute] bool sendInvitation, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Put("/v1/User/" + Routes.Id)] |         [Put("/v1/User/" + Routes.Id)] | ||||||
|         Task<UserAdapter> UpdateUserAsync([FromBody] UserAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default); |         Task<UserAdapter> UpdateUserAsync([FromBody] UserAdapter entity, [FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Delete("/v1/User/" + Routes.Id)] | ||||||
|  |         Task<UserAdapter> DeleteUserAsync([FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Patch("/v1/User/" + Routes.LogIn)] |         [Patch("/v1/User/" + Routes.LogIn)] | ||||||
|         Task<UserAdapter> LoginUserAsync([FromRoute] string email, CancellationToken cancellationToken = default); |         Task<UserAdapter> LoginUserAsync([FromRoute] string email, CancellationToken cancellationToken = default); | ||||||
| @@ -32,7 +35,7 @@ namespace Core.Thalos.External.Clients | |||||||
|         Task<UserAdapter> LogoutUserAsync([FromRoute] string email, CancellationToken cancellationToken = default); |         Task<UserAdapter> LogoutUserAsync([FromRoute] string email, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Patch("/v1/User/" + Routes.ChangeStatus)] |         [Patch("/v1/User/" + Routes.ChangeStatus)] | ||||||
|         Task<UserAdapter> ChangeUserStatusAsync([FromRoute] string id, Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default); |         Task<UserAdapter> ChangeUserStatusAsync([FromRoute] string _id, Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Get("/v1/User/{email}/GetTokenAdapter")] |         [Get("/v1/User/{email}/GetTokenAdapter")] | ||||||
|         Task<TokenAdapter> GetTokenAdapter([FromRoute] string email, CancellationToken cancellationToken = default); |         Task<TokenAdapter> GetTokenAdapter([FromRoute] string email, CancellationToken cancellationToken = default); | ||||||
| @@ -41,16 +44,19 @@ namespace Core.Thalos.External.Clients | |||||||
|         Task<IEnumerable<RoleAdapter>> GetAllRolesAsync(CancellationToken cancellationToken = default); |         Task<IEnumerable<RoleAdapter>> GetAllRolesAsync(CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Get("/v1/Role/" + Routes.Id)] |         [Get("/v1/Role/" + Routes.Id)] | ||||||
|         Task<RoleAdapter> GetRoleByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default); |         Task<RoleAdapter> GetRoleByIdAsync([FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Post("/v1/Role")] |         [Post("/v1/Role")] | ||||||
|         Task<RoleAdapter> CreateRoleAsync([FromBody] RoleRequest newRole, CancellationToken cancellationToken = default); |         Task<RoleAdapter> CreateRoleAsync([FromBody] RoleRequest newRole, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Put("/v1/Role/" + Routes.Id)] |         [Put("/v1/Role/" + Routes.Id)] | ||||||
|         Task<RoleAdapter> UpdateRoleAsync([FromBody] RoleAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default); |         Task<RoleAdapter> UpdateRoleAsync([FromBody] RoleAdapter entity, [FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Delete("/v1/Role/" + Routes.Id)] | ||||||
|  |         Task<RoleAdapter> DeleteRoleAsync([FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Patch("/v1/Role/" + Routes.ChangeStatus)] |         [Patch("/v1/Role/" + Routes.ChangeStatus)] | ||||||
|         Task<RoleAdapter> ChangeRoleStatusAsync([FromRoute] string id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default); |         Task<RoleAdapter> ChangeRoleStatusAsync([FromRoute] string _id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Post("/v1/Role/" + Routes.AddApplication)] |         [Post("/v1/Role/" + Routes.AddApplication)] | ||||||
|         Task<RoleAdapter> AddApplicationToRoleAsync([FromRoute] string RoleId, [FromRoute] ApplicationsEnum application, CancellationToken cancellationToken = default); |         Task<RoleAdapter> AddApplicationToRoleAsync([FromRoute] string RoleId, [FromRoute] ApplicationsEnum application, CancellationToken cancellationToken = default); | ||||||
| @@ -65,16 +71,19 @@ namespace Core.Thalos.External.Clients | |||||||
|         Task<IEnumerable<PermissionAdapter>> GetAllPermissionsByListAsync([FromBody] string[] request, CancellationToken cancellationToken = default); |         Task<IEnumerable<PermissionAdapter>> GetAllPermissionsByListAsync([FromBody] string[] request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Get("/v1/Permission/" + Routes.Id)] |         [Get("/v1/Permission/" + Routes.Id)] | ||||||
|         Task<PermissionAdapter> GetPermissionByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default); |         Task<PermissionAdapter> GetPermissionByIdAsync([FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Post("/v1/Permission")] |         [Post("/v1/Permission")] | ||||||
|         Task<PermissionAdapter> CreatePermissionAsync([FromBody] PermissionRequest newPermission, CancellationToken cancellationToken = default); |         Task<PermissionAdapter> CreatePermissionAsync([FromBody] PermissionRequest newPermission, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Put("/v1/Permission/" + Routes.Id)] |         [Put("/v1/Permission/" + Routes.Id)] | ||||||
|         Task<PermissionAdapter> UpdatePermissionAsync([FromBody] PermissionAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default); |         Task<PermissionAdapter> UpdatePermissionAsync([FromBody] PermissionAdapter entity, [FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Delete("/v1/Permission/" + Routes.Id)] | ||||||
|  |         Task<PermissionAdapter> DeletePermissionAsync([FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Patch("/v1/Permission/" + Routes.ChangeStatus)] |         [Patch("/v1/Permission/" + Routes.ChangeStatus)] | ||||||
|         Task<PermissionAdapter> ChangeStatusPermissionAsync([FromRoute] string id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default); |         Task<PermissionAdapter> ChangeStatusPermissionAsync([FromRoute] string _id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Get("/v1/Module")] |         [Get("/v1/Module")] | ||||||
|         Task<IEnumerable<ModuleAdapter>> GetAllModulesAsync(CancellationToken cancellationToken = default); |         Task<IEnumerable<ModuleAdapter>> GetAllModulesAsync(CancellationToken cancellationToken = default); | ||||||
| @@ -83,15 +92,36 @@ namespace Core.Thalos.External.Clients | |||||||
|         Task<IEnumerable<ModuleAdapter>> GetAllModulesByListAsync([FromBody] string[] request, CancellationToken cancellationToken = default); |         Task<IEnumerable<ModuleAdapter>> GetAllModulesByListAsync([FromBody] string[] request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Get("/v1/Module/" + Routes.Id)] |         [Get("/v1/Module/" + Routes.Id)] | ||||||
|         Task<ModuleAdapter> GetModuleByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default); |         Task<ModuleAdapter> GetModuleByIdAsync([FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Post("/v1/Module")] |         [Post("/v1/Module")] | ||||||
|         Task<ModuleAdapter> CreateModuleAsync([FromBody] ModuleRequest newModule, CancellationToken cancellationToken = default); |         Task<ModuleAdapter> CreateModuleAsync([FromBody] ModuleRequest newModule, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Put("/v1/Module/" + Routes.Id)] |         [Put("/v1/Module/" + Routes.Id)] | ||||||
|         Task<ModuleAdapter> UpdateModuleAsync([FromBody] ModuleAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default); |         Task<ModuleAdapter> UpdateModuleAsync([FromBody] ModuleAdapter entity, [FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Delete("/v1/Module/" + Routes.Id)] | ||||||
|  |         Task<ModuleAdapter> DeleteModuleAsync([FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Patch("/v1/Module/" + Routes.ChangeStatus)] |         [Patch("/v1/Module/" + Routes.ChangeStatus)] | ||||||
|         Task<ModuleAdapter> ChangeStatusModuleAsync([FromRoute] string id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default); |         Task<ModuleAdapter> ChangeStatusModuleAsync([FromRoute] string _id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Get("/v1/Tenant")] | ||||||
|  |         Task<IEnumerable<TenantAdapter>> GetAllTenantsAsync(CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Get("/v1/Tenant/" + Routes.Id)] | ||||||
|  |         Task<TenantAdapter> GetTenantByIdAsync([FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Post("/v1/Tenant")] | ||||||
|  |         Task<TenantAdapter> CreateTenantAsync([FromBody] TenantRequest newTenant, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Put("/v1/Tenant/" + Routes.Id)] | ||||||
|  |         Task<TenantAdapter> UpdateTenantAsync([FromBody] TenantAdapter entity, [FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Patch("/v1/Tenant/" + Routes.ChangeStatus)] | ||||||
|  |         Task<TenantAdapter> ChangeStatusTenantAsync([FromRoute] string _id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Delete("/v1/Tenant/" + Routes.Id)] | ||||||
|  |         Task<TenantAdapter> DeleteTenantAsync([FromRoute] string _id, CancellationToken cancellationToken = default); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										53
									
								
								Core.Thalos.External/Clients/Requests/TenantRequest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								Core.Thalos.External/Clients/Requests/TenantRequest.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | |||||||
|  | using Core.Blueprint.Mongo; | ||||||
|  | using MongoDB.Bson; | ||||||
|  | using MongoDB.Bson.Serialization.Attributes; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.BuildingBlocks | ||||||
|  | { | ||||||
|  |     [CollectionAttributeName("Tenants")] | ||||||
|  |     public class TenantRequest : Document | ||||||
|  |     { | ||||||
|  |         [BsonElement("name")] | ||||||
|  |         public string Name { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         [BsonElement("taxIdentifier")] | ||||||
|  |         public string TaxIdentifier { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         [BsonElement("addressLine1")] | ||||||
|  |         public string AddressLine1 { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         [BsonElement("addressLine2")] | ||||||
|  |         [BsonIgnoreIfNull] | ||||||
|  |         public string? AddressLine2 { get; set; } | ||||||
|  |  | ||||||
|  |         [BsonElement("city")] | ||||||
|  |         public string City { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         [BsonElement("state")] | ||||||
|  |         public string State { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         [BsonElement("country")] | ||||||
|  |         public string Country { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         [BsonElement("postalCode")] | ||||||
|  |         public string PostalCode { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         [BsonElement("contactEmail")] | ||||||
|  |         public string ContactEmail { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         [BsonElement("contactPhone")] | ||||||
|  |         public string ContactPhone { get; set; } = null!; | ||||||
|  |  | ||||||
|  |         [BsonElement("website")] | ||||||
|  |         [BsonIgnoreIfNull] | ||||||
|  |         public string? Website { get; set; } | ||||||
|  |  | ||||||
|  |         [BsonElement("connectionString")] | ||||||
|  |         [BsonIgnoreIfNull] | ||||||
|  |         public string? ConnectionString { get; set; } | ||||||
|  |  | ||||||
|  |         [BsonElement("isolated")] | ||||||
|  |         public bool Isolated { get; set; } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -8,7 +8,7 @@ | |||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="Core.Blueprint.Storage" Version="1.0.1" /> |     <PackageReference Include="Core.Blueprint.Storage" Version="1.0.1" /> | ||||||
|     <PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.8" /> |     <PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.1.4" /> | ||||||
|     <PackageReference Include="Lib.Architecture.BuildingBlocks" Version="1.0.0" /> |     <PackageReference Include="Lib.Architecture.BuildingBlocks" Version="1.0.0" /> | ||||||
|     <PackageReference Include="Refit" Version="8.0.0" /> |     <PackageReference Include="Refit" Version="8.0.0" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   | |||||||
| @@ -23,6 +23,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         private readonly IComponentHandler<GetAllModulesByListRequest> getAllModulesByListHandler; |         private readonly IComponentHandler<GetAllModulesByListRequest> getAllModulesByListHandler; | ||||||
|         private readonly IComponentHandler<CreateModuleRequest> createModuleHandler; |         private readonly IComponentHandler<CreateModuleRequest> createModuleHandler; | ||||||
|         private readonly IComponentHandler<UpdateModuleRequest> updateModuleHandler; |         private readonly IComponentHandler<UpdateModuleRequest> updateModuleHandler; | ||||||
|  |         private readonly IComponentHandler<DeleteModuleRequest> deleteModuleHandler; | ||||||
|         private readonly IComponentHandler<ChangeModuleStatusRequest> changeModuleStatusHandler; |         private readonly IComponentHandler<ChangeModuleStatusRequest> changeModuleStatusHandler; | ||||||
|         private readonly IModulePort port; |         private readonly IModulePort port; | ||||||
|  |  | ||||||
| @@ -35,12 +36,14 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|             IComponentHandler<GetAllModulesByListRequest> getAllModulesByListHandler, |             IComponentHandler<GetAllModulesByListRequest> getAllModulesByListHandler, | ||||||
|             IComponentHandler<CreateModuleRequest> createModuleHandler, |             IComponentHandler<CreateModuleRequest> createModuleHandler, | ||||||
|             IComponentHandler<UpdateModuleRequest> updateModuleHandler, |             IComponentHandler<UpdateModuleRequest> updateModuleHandler, | ||||||
|  |             IComponentHandler<DeleteModuleRequest> deleteModuleHandler, | ||||||
|             IComponentHandler<ChangeModuleStatusRequest> changeModuleStatusHandler, |             IComponentHandler<ChangeModuleStatusRequest> changeModuleStatusHandler, | ||||||
|             IModulePort port |             IModulePort port | ||||||
|             ) |             ) | ||||||
|         { |         { | ||||||
|             this.createModuleHandler = createModuleHandler; |             this.createModuleHandler = createModuleHandler; | ||||||
|             this.updateModuleHandler = updateModuleHandler; |             this.updateModuleHandler = updateModuleHandler; | ||||||
|  |             this.deleteModuleHandler = deleteModuleHandler; | ||||||
|             this.changeModuleStatusHandler = changeModuleStatusHandler; |             this.changeModuleStatusHandler = changeModuleStatusHandler; | ||||||
|             this.getAllModulesHandler = getAllModulesHandler; |             this.getAllModulesHandler = getAllModulesHandler; | ||||||
|             this.getModuleHandler = getModuleHandler; |             this.getModuleHandler = getModuleHandler; | ||||||
| @@ -104,7 +107,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets the module by identifier. |         /// Gets the module by mongo identifier. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [HttpPost] |         [HttpPost] | ||||||
|         [Route("GetById")] |         [Route("GetById")] | ||||||
| @@ -119,9 +122,9 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         public async Task<IActionResult> GetModuleById([FromBody] GetModuleRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> GetModuleById([FromBody] GetModuleRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|  |  | ||||||
|             if (request.Id == null || !request.Id.Any()) |             if (request._Id == null || !request._Id.Any()) | ||||||
|             { |             { | ||||||
|                 return BadRequest("Invalid Module Id"); |                 return BadRequest("Invalid Module _Id"); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             await getModuleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); |             await getModuleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
| @@ -149,7 +152,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Updates a full module by identifier. |         /// Updates a full module by mongo identifier. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [HttpPut("Update")] |         [HttpPut("Update")] | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
| @@ -167,6 +170,25 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|             return port.ViewModel; |             return port.ViewModel; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Deletes a full module by mongo identifier. | ||||||
|  |         /// </summary> | ||||||
|  |         [HttpDelete("Delete")] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||||
|  |         [Permission("ModuleManagement.Write")] | ||||||
|  |         public async Task<IActionResult> DeleteModuleAsync([FromBody] DeleteModuleRequest request, CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             await deleteModuleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|  |             return port.ViewModel; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Changes the status of the module. |         /// Changes the status of the module. | ||||||
|         /// </summary> |         /// </summary> | ||||||
| @@ -183,7 +205,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         public async Task<IActionResult> ChangeModuleStatusAsync([FromBody] ChangeModuleStatusRequest request, |         public async Task<IActionResult> ChangeModuleStatusAsync([FromBody] ChangeModuleStatusRequest request, | ||||||
|                                                                      CancellationToken cancellationToken) |                                                                      CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid module identifier"); } |             if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid module mongo identifier"); } | ||||||
|  |  | ||||||
|             await changeModuleStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); |             await changeModuleStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -23,6 +23,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         private readonly IComponentHandler<GetAllPermissionsByListRequest> getAllPermissionsByListHandler; |         private readonly IComponentHandler<GetAllPermissionsByListRequest> getAllPermissionsByListHandler; | ||||||
|         private readonly IComponentHandler<CreatePermissionRequest> createPermissionHandler; |         private readonly IComponentHandler<CreatePermissionRequest> createPermissionHandler; | ||||||
|         private readonly IComponentHandler<UpdatePermissionRequest> updatePermissionHandler; |         private readonly IComponentHandler<UpdatePermissionRequest> updatePermissionHandler; | ||||||
|  |         private readonly IComponentHandler<DeletePermissionRequest> deletePermissionHandler; | ||||||
|         private readonly IComponentHandler<ChangePermissionStatusRequest> changePermissionStatusHandler; |         private readonly IComponentHandler<ChangePermissionStatusRequest> changePermissionStatusHandler; | ||||||
|         private readonly IPermissionPort port; |         private readonly IPermissionPort port; | ||||||
|  |  | ||||||
| @@ -35,12 +36,14 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|             IComponentHandler<GetAllPermissionsByListRequest> getAllPermissionsByListHandler, |             IComponentHandler<GetAllPermissionsByListRequest> getAllPermissionsByListHandler, | ||||||
|             IComponentHandler<CreatePermissionRequest> createPermissionHandler, |             IComponentHandler<CreatePermissionRequest> createPermissionHandler, | ||||||
|             IComponentHandler<UpdatePermissionRequest> updatePermissionHandler, |             IComponentHandler<UpdatePermissionRequest> updatePermissionHandler, | ||||||
|  |             IComponentHandler<DeletePermissionRequest> deletePermissionHandler, | ||||||
|             IComponentHandler<ChangePermissionStatusRequest> changePermissionStatusHandler, |             IComponentHandler<ChangePermissionStatusRequest> changePermissionStatusHandler, | ||||||
|             IPermissionPort port |             IPermissionPort port | ||||||
|             ) |             ) | ||||||
|         { |         { | ||||||
|             this.createPermissionHandler = createPermissionHandler; |             this.createPermissionHandler = createPermissionHandler; | ||||||
|             this.updatePermissionHandler = updatePermissionHandler; |             this.updatePermissionHandler = updatePermissionHandler; | ||||||
|  |             this.deletePermissionHandler = deletePermissionHandler; | ||||||
|             this.changePermissionStatusHandler = changePermissionStatusHandler; |             this.changePermissionStatusHandler = changePermissionStatusHandler; | ||||||
|             this.getAllPermissionsHandler = getAllPermissionsHandler; |             this.getAllPermissionsHandler = getAllPermissionsHandler; | ||||||
|             this.getPermissionHandler = getPermissionHandler; |             this.getPermissionHandler = getPermissionHandler; | ||||||
| @@ -104,7 +107,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets the permission by identifier. |         /// Gets the permission by mongo identifier. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [HttpPost] |         [HttpPost] | ||||||
|         [Route("GetById")] |         [Route("GetById")] | ||||||
| @@ -119,9 +122,9 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         public async Task<IActionResult> GetPermissionById([FromBody] GetPermissionRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> GetPermissionById([FromBody] GetPermissionRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|  |  | ||||||
|             if (request.Id == null || !request.Id.Any()) |             if (request._Id == null || !request._Id.Any()) | ||||||
|             { |             { | ||||||
|                 return BadRequest("Invalid Permission Id"); |                 return BadRequest("Invalid Permission _Id"); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             await getPermissionHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); |             await getPermissionHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
| @@ -149,7 +152,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Updates a full permission by identifier. |         /// Updates a full permission by mongo identifier. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [HttpPut("Update")] |         [HttpPut("Update")] | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
| @@ -167,6 +170,25 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|             return port.ViewModel; |             return port.ViewModel; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Deletes a full permission by mongo identifier. | ||||||
|  |         /// </summary> | ||||||
|  |         [HttpDelete("Delete")] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||||
|  |         [Permission("PermissionManagement.Write")] | ||||||
|  |         public async Task<IActionResult> DeletePermissionAsync([FromBody] DeletePermissionRequest request, CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             await deletePermissionHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|  |             return port.ViewModel; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Changes the status of the permission. |         /// Changes the status of the permission. | ||||||
|         /// </summary> |         /// </summary> | ||||||
| @@ -183,7 +205,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         public async Task<IActionResult> ChangePermissionStatusAsync([FromBody] ChangePermissionStatusRequest request, |         public async Task<IActionResult> ChangePermissionStatusAsync([FromBody] ChangePermissionStatusRequest request, | ||||||
|                                                                      CancellationToken cancellationToken) |                                                                      CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid permission identifier"); } |             if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid permission mongo identifier"); } | ||||||
|  |  | ||||||
|             await changePermissionStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); |             await changePermissionStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         private readonly IComponentHandler<GetAllRolesRequest> getAllRolesHandler; |         private readonly IComponentHandler<GetAllRolesRequest> getAllRolesHandler; | ||||||
|         private readonly IComponentHandler<CreateRoleRequest> createRoleHandler; |         private readonly IComponentHandler<CreateRoleRequest> createRoleHandler; | ||||||
|         private readonly IComponentHandler<UpdateRoleRequest> updateRoleHandler; |         private readonly IComponentHandler<UpdateRoleRequest> updateRoleHandler; | ||||||
|  |         private readonly IComponentHandler<DeleteRoleRequest> deleteRoleHandler; | ||||||
|         private readonly IComponentHandler<ChangeRoleStatusRequest> changeStatusRoleHandler; |         private readonly IComponentHandler<ChangeRoleStatusRequest> changeStatusRoleHandler; | ||||||
|         private readonly IComponentHandler<AddApplicationToRoleRequest> addApplicationToRoleHandler; |         private readonly IComponentHandler<AddApplicationToRoleRequest> addApplicationToRoleHandler; | ||||||
|         private readonly IComponentHandler<RemoveApplicationFromRoleRequest> removeApplicationToRoleHandler; |         private readonly IComponentHandler<RemoveApplicationFromRoleRequest> removeApplicationToRoleHandler; | ||||||
| @@ -35,6 +36,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|             IComponentHandler<GetAllRolesRequest> getAllRolesHandler, |             IComponentHandler<GetAllRolesRequest> getAllRolesHandler, | ||||||
|             IComponentHandler<CreateRoleRequest> createRoleHandler, |             IComponentHandler<CreateRoleRequest> createRoleHandler, | ||||||
|             IComponentHandler<UpdateRoleRequest> updateRoleHandler, |             IComponentHandler<UpdateRoleRequest> updateRoleHandler, | ||||||
|  |             IComponentHandler<DeleteRoleRequest> deleteRoleHandler, | ||||||
|             IComponentHandler<ChangeRoleStatusRequest> changeRoleStatusHandler, |             IComponentHandler<ChangeRoleStatusRequest> changeRoleStatusHandler, | ||||||
|             IComponentHandler<AddApplicationToRoleRequest> addApplicationToRoleHandler, |             IComponentHandler<AddApplicationToRoleRequest> addApplicationToRoleHandler, | ||||||
|             IComponentHandler<RemoveApplicationFromRoleRequest> removeApplicationToRoleHandler, |             IComponentHandler<RemoveApplicationFromRoleRequest> removeApplicationToRoleHandler, | ||||||
| @@ -43,6 +45,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         { |         { | ||||||
|             this.createRoleHandler = createRoleHandler; |             this.createRoleHandler = createRoleHandler; | ||||||
|             this.updateRoleHandler = updateRoleHandler; |             this.updateRoleHandler = updateRoleHandler; | ||||||
|  |             this.deleteRoleHandler = deleteRoleHandler; | ||||||
|             this.changeStatusRoleHandler = changeRoleStatusHandler; |             this.changeStatusRoleHandler = changeRoleStatusHandler; | ||||||
|             this.getAllRolesHandler = getAllRolesHandler; |             this.getAllRolesHandler = getAllRolesHandler; | ||||||
|             this.getRoleHandler = getRoleHandler; |             this.getRoleHandler = getRoleHandler; | ||||||
| @@ -71,7 +74,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets the role by identifier. |         /// Gets the role by mongo identifier. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [HttpPost] |         [HttpPost] | ||||||
|         [Route("GetById")] |         [Route("GetById")] | ||||||
| @@ -85,7 +88,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         [Permission("RoleManagement.Read")] |         [Permission("RoleManagement.Read")] | ||||||
|         public async Task<IActionResult> GetRoleById([FromBody] GetRoleRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> GetRoleById([FromBody] GetRoleRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid role identifier"); } |             if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid role mongo identifier"); } | ||||||
|  |  | ||||||
|             await getRoleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); |             await getRoleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
| @@ -112,7 +115,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Updates a full role by identifier. |         /// Updates a full role by mongo identifier. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [HttpPut("Update")] |         [HttpPut("Update")] | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
| @@ -130,6 +133,25 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|             return port.ViewModel; |             return port.ViewModel; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Deletes a full role by mongo identifier. | ||||||
|  |         /// </summary> | ||||||
|  |         [HttpDelete("Delete")] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||||
|  |         [Permission("RoleManagement.Write")] | ||||||
|  |         public async Task<IActionResult> DeleteeRoleAsync([FromBody] DeleteRoleRequest entity, CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             await deleteRoleHandler.ExecuteAsync(entity, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|  |             return port.ViewModel; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Changes the status of the role. |         /// Changes the status of the role. | ||||||
|         /// </summary> |         /// </summary> | ||||||
| @@ -145,7 +167,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         [Permission("RoleManagement.Write")] |         [Permission("RoleManagement.Write")] | ||||||
|         public async Task<IActionResult> ChageRoleStatusAsync(ChangeRoleStatusRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> ChageRoleStatusAsync(ChangeRoleStatusRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid role identifier"); } |             if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid role mongo identifier"); } | ||||||
|  |  | ||||||
|             await changeStatusRoleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); |             await changeStatusRoleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
| @@ -167,7 +189,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         [Permission("RoleManagement.Write")] |         [Permission("RoleManagement.Write")] | ||||||
|         public async Task<IActionResult> AddApplicationToRoleAsync(AddApplicationToRoleRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> AddApplicationToRoleAsync(AddApplicationToRoleRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role identifier"); } |             if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role mongo identifier"); } | ||||||
|  |  | ||||||
|             await addApplicationToRoleHandler.ExecuteAsync(request, cancellationToken); |             await addApplicationToRoleHandler.ExecuteAsync(request, cancellationToken); | ||||||
|  |  | ||||||
| @@ -190,7 +212,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         public async Task<IActionResult> RemoveApplicationToRoleAsync(RemoveApplicationFromRoleRequest request, |         public async Task<IActionResult> RemoveApplicationToRoleAsync(RemoveApplicationFromRoleRequest request, | ||||||
|                                                                    CancellationToken cancellationToken) |                                                                    CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role identifier"); } |             if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role mongo identifier"); } | ||||||
|  |  | ||||||
|             await removeApplicationToRoleHandler.ExecuteAsync(request, cancellationToken); |             await removeApplicationToRoleHandler.ExecuteAsync(request, cancellationToken); | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										176
									
								
								Core.Thalos.Service.API/Controllers/TenantController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										176
									
								
								Core.Thalos.Service.API/Controllers/TenantController.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,176 @@ | |||||||
|  | using Asp.Versioning; | ||||||
|  | using Core.Thalos.Application.UseCases.Tenants.Input; | ||||||
|  | using Core.Thalos.Application.UseCases.Tenants.Ports; | ||||||
|  | using Core.Thalos.BuildingBlocks; | ||||||
|  | using Lib.Architecture.BuildingBlocks; | ||||||
|  | using Microsoft.AspNetCore.Authorization; | ||||||
|  | using Microsoft.AspNetCore.Mvc; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.Service.API.Controllers | ||||||
|  | { | ||||||
|  |     /// <summary> | ||||||
|  |     /// Handles all services and business rules related to <see cref="TenantController"/>. | ||||||
|  |     /// </summary> | ||||||
|  |     [ApiVersion("1.0")] | ||||||
|  |     [Route("api/v{api-version:apiVersion}/[controller]")] | ||||||
|  |     [Produces("application/json")] | ||||||
|  |     [ApiController] | ||||||
|  |     [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||||
|  |     public class TenantController : ControllerBase | ||||||
|  |     { | ||||||
|  |         private readonly IComponentHandler<GetTenantRequest> getTenantHandler; | ||||||
|  |         private readonly IComponentHandler<GetAllTenantsRequest> getAllTenantsHandler; | ||||||
|  |         private readonly IComponentHandler<CreateTenantRequest> createTenantHandler; | ||||||
|  |         private readonly IComponentHandler<UpdateTenantRequest> updateTenantHandler; | ||||||
|  |         private readonly IComponentHandler<DeleteTenantRequest> deleteTenantHandler; | ||||||
|  |         private readonly IComponentHandler<ChangeTenantStatusRequest> changeTenantStatusHandler; | ||||||
|  |         private readonly ITenantPort port; | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Handles all services and business rules related to <see cref="TenantController"/>. | ||||||
|  |         /// </summary> | ||||||
|  |         public TenantController( | ||||||
|  |             IComponentHandler<GetTenantRequest> getTenantHandler, | ||||||
|  |             IComponentHandler<GetAllTenantsRequest> getAllTenantsHandler, | ||||||
|  |             IComponentHandler<CreateTenantRequest> createTenantHandler, | ||||||
|  |             IComponentHandler<UpdateTenantRequest> updateTenantHandler, | ||||||
|  |             IComponentHandler<DeleteTenantRequest> deleteTenantHandler, | ||||||
|  |             IComponentHandler<ChangeTenantStatusRequest> changeTenantStatusHandler, | ||||||
|  |             ITenantPort port | ||||||
|  |             ) | ||||||
|  |         { | ||||||
|  |             this.createTenantHandler = createTenantHandler; | ||||||
|  |             this.updateTenantHandler = updateTenantHandler; | ||||||
|  |             this.deleteTenantHandler = deleteTenantHandler; | ||||||
|  |             this.changeTenantStatusHandler = changeTenantStatusHandler; | ||||||
|  |             this.getAllTenantsHandler = getAllTenantsHandler; | ||||||
|  |             this.getTenantHandler = getTenantHandler; | ||||||
|  |             this.port = port; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets all the Tenants. | ||||||
|  |         /// </summary> | ||||||
|  |         [HttpGet("GetAll")] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||||
|  |         [Permission("TenantManagement.Read, RoleManagement.Read")] | ||||||
|  |         public async Task<IActionResult> GetAllTenantsAsync(CancellationToken cancellationToken) | ||||||
|  |         { | ||||||
|  |             await getAllTenantsHandler.ExecuteAsync(new GetAllTenantsRequest { }, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|  |             return port.ViewModel; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Gets the Tenant by mongo identifier. | ||||||
|  |         /// </summary> | ||||||
|  |         [HttpPost] | ||||||
|  |         [Route("GetById")] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|  |         [Permission("TenantManagement.Read")] | ||||||
|  |         public async Task<IActionResult> GetTenantById([FromBody] GetTenantRequest request, CancellationToken cancellationToken) | ||||||
|  |         { | ||||||
|  |  | ||||||
|  |             if (request._Id == null || !request._Id.Any()) | ||||||
|  |             { | ||||||
|  |                 return BadRequest("Invalid Tenant _Id"); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             await getTenantHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|  |             return port.ViewModel; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Creates a new Tenant. | ||||||
|  |         /// </summary> | ||||||
|  |         [HttpPost("Create")] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||||
|  |         [Permission("TenantManagement.Write")] | ||||||
|  |         public async Task<IActionResult> CreateTenantAsync([FromBody] CreateTenantRequest newTenant, CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             await createTenantHandler.ExecuteAsync(newTenant, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|  |             return port.ViewModel; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Updates a full Tenant by mongo identifier. | ||||||
|  |         /// </summary> | ||||||
|  |         [HttpPut("Update")] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||||
|  |         [Permission("TenantManagement.Write")] | ||||||
|  |         public async Task<IActionResult> UpdateTenantAsync([FromBody] UpdateTenantRequest request, CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             await updateTenantHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|  |             return port.ViewModel; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Deletes a full Tenant by mongo identifier. | ||||||
|  |         /// </summary> | ||||||
|  |         [HttpDelete("Delete")] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||||
|  |         [Permission("TenantManagement.Write")] | ||||||
|  |         public async Task<IActionResult> DeleteTenantAsync([FromBody] DeleteTenantRequest request, CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             await deleteTenantHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|  |             return port.ViewModel; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Changes the status of the Tenant. | ||||||
|  |         /// </summary> | ||||||
|  |         [HttpPatch] | ||||||
|  |         [Route("ChangeStatus")] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|  |         [Permission("TenantManagement.Write")] | ||||||
|  |         public async Task<IActionResult> ChangeTenantStatusAsync([FromBody] ChangeTenantStatusRequest request, | ||||||
|  |                                                                      CancellationToken cancellationToken) | ||||||
|  |         { | ||||||
|  |             if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid Tenant mongo identifier"); } | ||||||
|  |  | ||||||
|  |             await changeTenantStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|  |             return port.ViewModel; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -22,6 +22,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         private readonly IComponentHandler<GetAllUsersRequest> getAllUsersHandler; |         private readonly IComponentHandler<GetAllUsersRequest> getAllUsersHandler; | ||||||
|         private readonly IComponentHandler<CreateUserRequest> createUserHandler; |         private readonly IComponentHandler<CreateUserRequest> createUserHandler; | ||||||
|         private readonly IComponentHandler<UpdateUserRequest> updateUserHandler; |         private readonly IComponentHandler<UpdateUserRequest> updateUserHandler; | ||||||
|  |         private readonly IComponentHandler<DeleteUserRequest> deleteUserHandler; | ||||||
|         private readonly IComponentHandler<ChangeUserStatusRequest> ChangeUserStatusHandler; |         private readonly IComponentHandler<ChangeUserStatusRequest> ChangeUserStatusHandler; | ||||||
|         private readonly IComponentHandler<LoginUserRequest> loginUserHandler; |         private readonly IComponentHandler<LoginUserRequest> loginUserHandler; | ||||||
|         private readonly IComponentHandler<LogoutUserRequest> logoutUserHandler; |         private readonly IComponentHandler<LogoutUserRequest> logoutUserHandler; | ||||||
| @@ -38,6 +39,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|             IComponentHandler<GetAllUsersRequest> getAllUsersHandler, |             IComponentHandler<GetAllUsersRequest> getAllUsersHandler, | ||||||
|             IComponentHandler<CreateUserRequest> createUserHandler, |             IComponentHandler<CreateUserRequest> createUserHandler, | ||||||
|             IComponentHandler<UpdateUserRequest> updateUserHandler, |             IComponentHandler<UpdateUserRequest> updateUserHandler, | ||||||
|  |             IComponentHandler<DeleteUserRequest> deleteUserHandler, | ||||||
|             IComponentHandler<ChangeUserStatusRequest> changeUserStatusHandler, |             IComponentHandler<ChangeUserStatusRequest> changeUserStatusHandler, | ||||||
|             IComponentHandler<LoginUserRequest> loginUserHandler, |             IComponentHandler<LoginUserRequest> loginUserHandler, | ||||||
|             IComponentHandler<LogoutUserRequest> logoutUserHandler, |             IComponentHandler<LogoutUserRequest> logoutUserHandler, | ||||||
| @@ -48,6 +50,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         { |         { | ||||||
|             this.createUserHandler = createUserHandler; |             this.createUserHandler = createUserHandler; | ||||||
|             this.updateUserHandler = updateUserHandler; |             this.updateUserHandler = updateUserHandler; | ||||||
|  |             this.deleteUserHandler = deleteUserHandler; | ||||||
|             this.ChangeUserStatusHandler = changeUserStatusHandler; |             this.ChangeUserStatusHandler = changeUserStatusHandler; | ||||||
|             this.getAllUsersHandler = getAllUsersHandler; |             this.getAllUsersHandler = getAllUsersHandler; | ||||||
|             this.getUserHandler = getUserHandler; |             this.getUserHandler = getUserHandler; | ||||||
| @@ -80,7 +83,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets the user by identifier. |         /// Gets the user by mongo identifier. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [HttpPost] |         [HttpPost] | ||||||
|         [Route("GetById")] |         [Route("GetById")] | ||||||
| @@ -95,7 +98,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         [Permission("UserManagement.Read")] |         [Permission("UserManagement.Read")] | ||||||
|         public async Task<IActionResult> GetUserById([FromBody] GetUserRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> GetUserById([FromBody] GetUserRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid user identifier"); } |             if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid user mongo identifier"); } | ||||||
|  |  | ||||||
|             await getUserHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); |             await getUserHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
| @@ -146,7 +149,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Updates a full user by identifier. |         /// Updates a full user by mongo identifier. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [HttpPut("Update")] |         [HttpPut("Update")] | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
| @@ -166,6 +169,27 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|             return port.ViewModel; |             return port.ViewModel; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Deletes a full user by mongo identifier. | ||||||
|  |         /// </summary> | ||||||
|  |         [HttpDelete("Delete")] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|  |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|  |         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||||
|  |         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||||
|  |         [Permission("UserManagement.Write")] | ||||||
|  |         public async Task<IActionResult> DeleteUserAsync([FromBody] DeleteUserRequest request, | ||||||
|  |                                                          CancellationToken cancellationToken = default) | ||||||
|  |         { | ||||||
|  |             await deleteUserHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|  |             return port.ViewModel; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Logs in the user. |         /// Logs in the user. | ||||||
|         /// </summary> |         /// </summary> | ||||||
| @@ -223,7 +247,7 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         [Permission("UserManagement.Write")] |         [Permission("UserManagement.Write")] | ||||||
|         public async Task<IActionResult> ChangeUserStatusAsync([FromBody] ChangeUserStatusRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> ChangeUserStatusAsync([FromBody] ChangeUserStatusRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid user identifier"); } |             if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid user mongo identifier"); } | ||||||
|  |  | ||||||
|             await ChangeUserStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); |             await ChangeUserStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -13,6 +13,11 @@ using Core.Thalos.Application.UseCases.Roles.Adapter; | |||||||
| using Core.Thalos.Application.UseCases.Roles.Input; | using Core.Thalos.Application.UseCases.Roles.Input; | ||||||
| using Core.Thalos.Application.UseCases.Roles.Ports; | using Core.Thalos.Application.UseCases.Roles.Ports; | ||||||
| using Core.Thalos.Application.UseCases.Roles.Validator; | using Core.Thalos.Application.UseCases.Roles.Validator; | ||||||
|  | using Core.Thalos.Application.UseCases.Tenants; | ||||||
|  | using Core.Thalos.Application.UseCases.Tenants.Adapter; | ||||||
|  | using Core.Thalos.Application.UseCases.Tenants.Input; | ||||||
|  | using Core.Thalos.Application.UseCases.Tenants.Ports; | ||||||
|  | using Core.Thalos.Application.UseCases.Tenants.Validator; | ||||||
| using Core.Thalos.Application.UseCases.Users; | using Core.Thalos.Application.UseCases.Users; | ||||||
| using Core.Thalos.Application.UseCases.Users.Adapter; | using Core.Thalos.Application.UseCases.Users.Adapter; | ||||||
| using Core.Thalos.Application.UseCases.Users.Input; | using Core.Thalos.Application.UseCases.Users.Input; | ||||||
| @@ -32,6 +37,7 @@ namespace Core.Thalos.Service.API.Extensions | |||||||
|             services.AddScoped<IUserPort, UserPort>(); |             services.AddScoped<IUserPort, UserPort>(); | ||||||
|             services.AddScoped<IComponentHandler<GetAllUsersRequest>, UserHandler>(); |             services.AddScoped<IComponentHandler<GetAllUsersRequest>, UserHandler>(); | ||||||
|             services.AddScoped<IComponentHandler<GetUserRequest>, UserHandler>(); |             services.AddScoped<IComponentHandler<GetUserRequest>, UserHandler>(); | ||||||
|  |             services.AddScoped<IComponentHandler<DeleteUserRequest>, UserHandler>(); | ||||||
|             services.AddScoped<IComponentHandler<LoginUserRequest>, UserHandler>(); |             services.AddScoped<IComponentHandler<LoginUserRequest>, UserHandler>(); | ||||||
|             services.AddScoped<IComponentHandler<LogoutUserRequest>, UserHandler>(); |             services.AddScoped<IComponentHandler<LogoutUserRequest>, UserHandler>(); | ||||||
|             services.AddScoped<IComponentHandler<GetUserByEmailRequest>, UserHandler>(); |             services.AddScoped<IComponentHandler<GetUserByEmailRequest>, UserHandler>(); | ||||||
| @@ -58,6 +64,7 @@ namespace Core.Thalos.Service.API.Extensions | |||||||
|             services.AddScoped<IRolePort, RolePort>(); |             services.AddScoped<IRolePort, RolePort>(); | ||||||
|             services.AddScoped<IComponentHandler<GetAllRolesRequest>, RoleHandler>(); |             services.AddScoped<IComponentHandler<GetAllRolesRequest>, RoleHandler>(); | ||||||
|             services.AddScoped<IComponentHandler<GetRoleRequest>, RoleHandler>(); |             services.AddScoped<IComponentHandler<GetRoleRequest>, RoleHandler>(); | ||||||
|  |             services.AddScoped<IComponentHandler<DeleteRoleRequest>, RoleHandler>(); | ||||||
|             services.AddScoped<IComponentHandler<AddApplicationToRoleRequest>, RoleHandler>(); |             services.AddScoped<IComponentHandler<AddApplicationToRoleRequest>, RoleHandler>(); | ||||||
|             services.AddScoped<IComponentHandler<RemoveApplicationFromRoleRequest>, RoleHandler>(); |             services.AddScoped<IComponentHandler<RemoveApplicationFromRoleRequest>, RoleHandler>(); | ||||||
|  |  | ||||||
| @@ -80,6 +87,7 @@ namespace Core.Thalos.Service.API.Extensions | |||||||
|             services.AddScoped<IPermissionPort, PermissionPort>(); |             services.AddScoped<IPermissionPort, PermissionPort>(); | ||||||
|             services.AddScoped<IComponentHandler<GetAllPermissionsRequest>, PermissionHandler>(); |             services.AddScoped<IComponentHandler<GetAllPermissionsRequest>, PermissionHandler>(); | ||||||
|             services.AddScoped<IComponentHandler<GetPermissionRequest>, PermissionHandler>(); |             services.AddScoped<IComponentHandler<GetPermissionRequest>, PermissionHandler>(); | ||||||
|  |             services.AddScoped<IComponentHandler<DeletePermissionRequest>, PermissionHandler>(); | ||||||
|             services.AddScoped<IComponentHandler<GetAllPermissionsByListRequest>, PermissionHandler>(); |             services.AddScoped<IComponentHandler<GetAllPermissionsByListRequest>, PermissionHandler>(); | ||||||
|  |  | ||||||
|             services.AddValidatorsFromAssemblyContaining<CreatePermissionValidator>(); |             services.AddValidatorsFromAssemblyContaining<CreatePermissionValidator>(); | ||||||
| @@ -101,6 +109,7 @@ namespace Core.Thalos.Service.API.Extensions | |||||||
|             services.AddScoped<IModulePort, ModulePort>(); |             services.AddScoped<IModulePort, ModulePort>(); | ||||||
|             services.AddScoped<IComponentHandler<GetAllModulesRequest>, ModuleHandler>(); |             services.AddScoped<IComponentHandler<GetAllModulesRequest>, ModuleHandler>(); | ||||||
|             services.AddScoped<IComponentHandler<GetModuleRequest>, ModuleHandler>(); |             services.AddScoped<IComponentHandler<GetModuleRequest>, ModuleHandler>(); | ||||||
|  |             services.AddScoped<IComponentHandler<DeleteModuleRequest>, ModuleHandler>(); | ||||||
|  |  | ||||||
|             services.AddValidatorsFromAssemblyContaining<GetAllModulesByListValidator>(); |             services.AddValidatorsFromAssemblyContaining<GetAllModulesByListValidator>(); | ||||||
|             services.AddScoped<IValidator<GetAllModulesByListRequest>, GetAllModulesByListValidator>(); |             services.AddScoped<IValidator<GetAllModulesByListRequest>, GetAllModulesByListValidator>(); | ||||||
| @@ -120,6 +129,27 @@ namespace Core.Thalos.Service.API.Extensions | |||||||
|  |  | ||||||
|             #endregion |             #endregion | ||||||
|  |  | ||||||
|  |             #region Tenant Services | ||||||
|  |  | ||||||
|  |             services.AddScoped<ITenantPort, TenantPort>(); | ||||||
|  |             services.AddScoped<IComponentHandler<GetAllTenantsRequest>, TenantHandler>(); | ||||||
|  |             services.AddScoped<IComponentHandler<GetTenantRequest>, TenantHandler>(); | ||||||
|  |             services.AddScoped<IComponentHandler<DeleteTenantRequest>, TenantHandler>(); | ||||||
|  |  | ||||||
|  |             services.AddValidatorsFromAssemblyContaining<CreateTenantValidator>(); | ||||||
|  |             services.AddScoped<IValidator<CreateTenantRequest>, CreateTenantValidator>(); | ||||||
|  |             services.AddScoped<IComponentHandler<CreateTenantRequest>, TenantHandler>(); | ||||||
|  |  | ||||||
|  |             services.AddValidatorsFromAssemblyContaining<UpdateTenantValidator>(); | ||||||
|  |             services.AddScoped<IValidator<UpdateTenantRequest>, UpdateTenantValidator>(); | ||||||
|  |             services.AddScoped<IComponentHandler<UpdateTenantRequest>, TenantHandler>(); | ||||||
|  |  | ||||||
|  |             services.AddValidatorsFromAssemblyContaining<ChangeTenantStatusValidator>(); | ||||||
|  |             services.AddScoped<IValidator<ChangeTenantStatusRequest>, ChangeTenantStatusValidator>(); | ||||||
|  |             services.AddScoped<IComponentHandler<ChangeTenantStatusRequest>, TenantHandler>(); | ||||||
|  |  | ||||||
|  |             #endregion | ||||||
|  |  | ||||||
|             return services; |             return services; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user