Add tenant services, change id by _id and include delete endpoint for all entities
This commit is contained in:
		| @@ -5,12 +5,12 @@ namespace Core.Thalos.Application.UseCases.Permissions.Input | ||||
| { | ||||
|     public class ChangePermissionStatusRequest : Notificator, ICommand | ||||
|     { | ||||
|         public string Id { get; set; } | ||||
|         public string _Id { get; set; } | ||||
|         public StatusEnum Status { get; set; } | ||||
|  | ||||
|         public bool Validate() | ||||
|         { | ||||
|             return Id != null; | ||||
|             return _Id != null; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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 string Id { get; set; } | ||||
|         public string _Id { get; set; } | ||||
|         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 string Id { get; set; } = null!; | ||||
|         public string _Id { get; set; } = null!; | ||||
|         public string Name { get; set; } = null!; | ||||
|         public string? Description { get; set; } | ||||
|         public AccessLevelEnum? AccessLevel { get; set; } = null!; | ||||
|         public Blueprint.Mongo.StatusEnum Status { get; set; } | ||||
|         public bool Validate() | ||||
|         { | ||||
|             return Id != null; | ||||
|             return _Id != null; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -15,6 +15,7 @@ namespace Core.Thalos.Application.UseCases.Permissions | ||||
|         IComponentHandler<GetAllPermissionsByListRequest>, | ||||
|         IComponentHandler<UpdatePermissionRequest>, | ||||
|         IComponentHandler<GetPermissionRequest>, | ||||
|         IComponentHandler<DeletePermissionRequest>, | ||||
|         IComponentHandler<CreatePermissionRequest> | ||||
|     { | ||||
|         private readonly IPermissionPort _port; | ||||
| @@ -43,7 +44,29 @@ namespace Core.Thalos.Application.UseCases.Permissions | ||||
|             { | ||||
|                 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) | ||||
|                 { | ||||
| @@ -111,7 +134,7 @@ namespace Core.Thalos.Application.UseCases.Permissions | ||||
|                     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) | ||||
|                 { | ||||
| @@ -176,13 +199,13 @@ namespace Core.Thalos.Application.UseCases.Permissions | ||||
|  | ||||
|                 var request = new PermissionAdapter | ||||
|                 { | ||||
|                     Id = command.Id, | ||||
|                     _Id = command._Id, | ||||
|                     Name = command.Name, | ||||
|                     Description = command.Description, | ||||
|                     AccessLevel = command.AccessLevel | ||||
|                 }; | ||||
|  | ||||
|                 string id = command.Id; | ||||
|                 string id = command._Id; | ||||
|  | ||||
|                 var result = await _thalosDALService.UpdatePermissionAsync(request, id, cancellationToken).ConfigureAwait(false); | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,7 @@ namespace Core.Thalos.Application.UseCases.Permissions.Validator | ||||
|     { | ||||
|         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."); | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Sergio Matias Urquin
					Sergio Matias Urquin