Add physical delete
This commit is contained in:
		| @@ -0,0 +1,14 @@ | ||||
| using Lib.Architecture.BuildingBlocks; | ||||
|  | ||||
| namespace Core.Inventory.Application.UseCases.Tag.Input | ||||
| { | ||||
|     public class DeleteTagRequest : Notificator, ICommand | ||||
|     { | ||||
|         public string Id { get; set; } = null!; | ||||
|  | ||||
|         public bool Validate() | ||||
|         { | ||||
|             return Id != null; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -17,7 +17,8 @@ namespace Core.Inventory.Application.UseCases.Tag | ||||
|         IComponentHandler<GetTagRequest>, | ||||
|         IComponentHandler<CreateTagRequest>, | ||||
|         IComponentHandler<AddParentTagToTagRequest>, | ||||
|         IComponentHandler<RemoveParentTagFromTagRequest> | ||||
|         IComponentHandler<RemoveParentTagFromTagRequest>, | ||||
|         IComponentHandler<DeleteTagRequest> | ||||
|     { | ||||
|         private readonly ITagPort _port; | ||||
|         private readonly IValidator<ChangeTagStatusRequest> _changeTagStatusValidator; | ||||
| @@ -25,6 +26,7 @@ namespace Core.Inventory.Application.UseCases.Tag | ||||
|         private readonly IValidator<UpdateTagRequest> _updateTagValidator; | ||||
|         private readonly IValidator<GetAllTagsByListRequest> _TagsByListValidator; | ||||
|         private readonly IInventoryServiceClient _inventoryServiceClient; | ||||
|         private readonly IValidator<DeleteTagRequest> _deleteTagValidator; | ||||
|  | ||||
|         public TagHandler( | ||||
|             ITagPort port, | ||||
| @@ -32,6 +34,7 @@ namespace Core.Inventory.Application.UseCases.Tag | ||||
|             IValidator<CreateTagRequest> registerTagValidator, | ||||
|             IValidator<UpdateTagRequest> updateTagValidator, | ||||
|             IValidator<GetAllTagsByListRequest> TagsByListValidator, | ||||
|             IValidator<DeleteTagRequest> deleteTagValidator, | ||||
|             IInventoryServiceClient inventoryDALService) | ||||
|         { | ||||
|             _port = port ?? throw new ArgumentNullException(nameof(port)); | ||||
| @@ -40,6 +43,7 @@ namespace Core.Inventory.Application.UseCases.Tag | ||||
|             _updateTagValidator = updateTagValidator ?? throw new ArgumentNullException(nameof(updateTagValidator)); | ||||
|             _inventoryServiceClient = inventoryDALService ?? throw new ArgumentNullException(nameof(inventoryDALService)); | ||||
|             _TagsByListValidator = TagsByListValidator ?? throw new ArgumentNullException(nameof(TagsByListValidator)); | ||||
|             _deleteTagValidator = deleteTagValidator ?? throw new ArgumentNullException(nameof(deleteTagValidator)); | ||||
|         } | ||||
|  | ||||
|         public async ValueTask ExecuteAsync(GetTagRequest command, CancellationToken cancellationToken = default) | ||||
| @@ -262,5 +266,33 @@ namespace Core.Inventory.Application.UseCases.Tag | ||||
|                 ApiResponseHelper.EvaluatePort(ex, _port); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public async ValueTask ExecuteAsync(DeleteTagRequest command, CancellationToken cancellationToken = default) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 ArgumentNullException.ThrowIfNull(command); | ||||
|  | ||||
|                 if (!command.IsValid(_deleteTagValidator)) | ||||
|                 { | ||||
|                     _port.ValidationErrors(command.Notifications); | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 var result = await _inventoryServiceClient.DeleteTagAsync(command.Id, cancellationToken).ConfigureAwait(false); | ||||
|  | ||||
|                 if (result == null) | ||||
|                 { | ||||
|                     _port.NoContentSuccess(); | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 _port.Success(result); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 ApiResponseHelper.EvaluatePort(ex, _port); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,13 @@ | ||||
| using Core.Inventory.Application.UseCases.Tag.Input; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace Core.Inventory.Application.UseCases.Tag.Validator | ||||
| { | ||||
|     public class DeleteTagValidator : AbstractValidator<DeleteTagRequest> | ||||
|     { | ||||
|         public DeleteTagValidator() | ||||
|         { | ||||
|             RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Tag Id").WithMessage("Tag Id is Obligatory."); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,14 @@ | ||||
| using Lib.Architecture.BuildingBlocks; | ||||
|  | ||||
| namespace Core.Inventory.Application.UseCases.TagOverride.Input | ||||
| { | ||||
|     public class DeleteTagOverrideRequest : Notificator, ICommand | ||||
|     { | ||||
|         public string Id { get; set; } = null!; | ||||
|  | ||||
|         public bool Validate() | ||||
|         { | ||||
|             return Id != null; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -15,7 +15,8 @@ namespace Core.Inventory.Application.UseCases.TagOverride | ||||
|         IComponentHandler<GetAllTagOverridesByListRequest>, | ||||
|         IComponentHandler<UpdateTagOverrideRequest>, | ||||
|         IComponentHandler<GetTagOverrideRequest>, | ||||
|         IComponentHandler<CreateTagOverrideRequest> | ||||
|         IComponentHandler<CreateTagOverrideRequest>, | ||||
|         IComponentHandler<DeleteTagOverrideRequest> | ||||
|     { | ||||
|         private readonly ITagOverridePort _port; | ||||
|         private readonly IValidator<ChangeTagOverrideStatusRequest> _changeTagOverrideStatusValidator; | ||||
| @@ -23,6 +24,7 @@ namespace Core.Inventory.Application.UseCases.TagOverride | ||||
|         private readonly IValidator<UpdateTagOverrideRequest> _updateTagOverrideValidator; | ||||
|         private readonly IValidator<GetAllTagOverridesByListRequest> _TagOverridesByListValidator; | ||||
|         private readonly IInventoryServiceClient _inventoryServiceClient; | ||||
|         private readonly IValidator<DeleteTagOverrideRequest> _deleteTagOverrideValidator; | ||||
|  | ||||
|         public TagOverrideHandler( | ||||
|             ITagOverridePort port, | ||||
| @@ -30,6 +32,7 @@ namespace Core.Inventory.Application.UseCases.TagOverride | ||||
|             IValidator<CreateTagOverrideRequest> registerTagOverrideValidator, | ||||
|             IValidator<UpdateTagOverrideRequest> updateTagOverrideValidator, | ||||
|             IValidator<GetAllTagOverridesByListRequest> TagOverridesByListValidator, | ||||
|             IValidator<DeleteTagOverrideRequest> deleteTagOverrideValidator, | ||||
|             IInventoryServiceClient inventoryDALService) | ||||
|         { | ||||
|             _port = port ?? throw new ArgumentNullException(nameof(port)); | ||||
| @@ -38,6 +41,7 @@ namespace Core.Inventory.Application.UseCases.TagOverride | ||||
|             _updateTagOverrideValidator = updateTagOverrideValidator ?? throw new ArgumentNullException(nameof(updateTagOverrideValidator)); | ||||
|             _inventoryServiceClient = inventoryDALService ?? throw new ArgumentNullException(nameof(inventoryDALService)); | ||||
|             _TagOverridesByListValidator = TagOverridesByListValidator ?? throw new ArgumentNullException(nameof(TagOverridesByListValidator)); | ||||
|             _deleteTagOverrideValidator = deleteTagOverrideValidator ?? throw new ArgumentNullException(nameof(deleteTagOverrideValidator)); | ||||
|         } | ||||
|  | ||||
|         public async ValueTask ExecuteAsync(GetTagOverrideRequest command, CancellationToken cancellationToken = default) | ||||
| @@ -208,5 +212,33 @@ namespace Core.Inventory.Application.UseCases.TagOverride | ||||
|                 ApiResponseHelper.EvaluatePort(ex, _port); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public async ValueTask ExecuteAsync(DeleteTagOverrideRequest command, CancellationToken cancellationToken = default) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 ArgumentNullException.ThrowIfNull(command); | ||||
|  | ||||
|                 if (!command.IsValid(_deleteTagOverrideValidator)) | ||||
|                 { | ||||
|                     _port.ValidationErrors(command.Notifications); | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 var result = await _inventoryServiceClient.DeleteTagOverrideAsync(command.Id, cancellationToken).ConfigureAwait(false); | ||||
|  | ||||
|                 if (result == null) | ||||
|                 { | ||||
|                     _port.NoContentSuccess(); | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 _port.Success(result); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 ApiResponseHelper.EvaluatePort(ex, _port); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,13 @@ | ||||
| using Core.Inventory.Application.UseCases.TagOverride.Input; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace Core.Inventory.Application.UseCases.TagOverride.Validator | ||||
| { | ||||
|     public class DeleteTagOverrideValidator : AbstractValidator<DeleteTagOverrideRequest> | ||||
|     { | ||||
|         public DeleteTagOverrideValidator() | ||||
|         { | ||||
|             RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("TagOverride Id").WithMessage("TagOverride Id is Obligatory."); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,14 @@ | ||||
| using Lib.Architecture.BuildingBlocks; | ||||
|  | ||||
| namespace Core.Inventory.Application.UseCases.TagType.Input | ||||
| { | ||||
|     public class DeleteTagTypeRequest : Notificator, ICommand | ||||
|     { | ||||
|         public string Id { get; set; } = null!; | ||||
|  | ||||
|         public bool Validate() | ||||
|         { | ||||
|             return Id != null; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -15,13 +15,15 @@ namespace Core.Inventory.Application.UseCases.TagType | ||||
|         IComponentHandler<GetAllTagTypesByListRequest>, | ||||
|         IComponentHandler<UpdateTagTypeRequest>, | ||||
|         IComponentHandler<GetTagTypeRequest>, | ||||
|         IComponentHandler<CreateTagTypeRequest> | ||||
|         IComponentHandler<CreateTagTypeRequest>, | ||||
|         IComponentHandler<DeleteTagTypeRequest> | ||||
|     { | ||||
|         private readonly ITagTypePort _port; | ||||
|         private readonly IValidator<ChangeTagTypeStatusRequest> _changeTagTypeStatusValidator; | ||||
|         private readonly IValidator<CreateTagTypeRequest> _registerTagTypeValidator; | ||||
|         private readonly IValidator<UpdateTagTypeRequest> _updateTagTypeValidator; | ||||
|         private readonly IValidator<GetAllTagTypesByListRequest> _TagTypesByListValidator; | ||||
|         private readonly IValidator<DeleteTagTypeRequest> _deleteTagTypeValidator; | ||||
|         private readonly IInventoryServiceClient _inventoryServiceClient; | ||||
|  | ||||
|         public TagTypeHandler( | ||||
| @@ -30,6 +32,7 @@ namespace Core.Inventory.Application.UseCases.TagType | ||||
|             IValidator<CreateTagTypeRequest> registerTagTypeValidator, | ||||
|             IValidator<UpdateTagTypeRequest> updateTagTypeValidator, | ||||
|             IValidator<GetAllTagTypesByListRequest> TagTypesByListValidator, | ||||
|             IValidator<DeleteTagTypeRequest> deleteTagTypeValidator, | ||||
|             IInventoryServiceClient inventoryDALService) | ||||
|         { | ||||
|             _port = port ?? throw new ArgumentNullException(nameof(port)); | ||||
| @@ -38,6 +41,7 @@ namespace Core.Inventory.Application.UseCases.TagType | ||||
|             _updateTagTypeValidator = updateTagTypeValidator ?? throw new ArgumentNullException(nameof(updateTagTypeValidator)); | ||||
|             _inventoryServiceClient = inventoryDALService ?? throw new ArgumentNullException(nameof(inventoryDALService)); | ||||
|             _TagTypesByListValidator = TagTypesByListValidator ?? throw new ArgumentNullException(nameof(TagTypesByListValidator)); | ||||
|             _deleteTagTypeValidator = deleteTagTypeValidator ?? throw new ArgumentNullException(nameof(deleteTagTypeValidator)); | ||||
|         } | ||||
|  | ||||
|         public async ValueTask ExecuteAsync(GetTagTypeRequest command, CancellationToken cancellationToken = default) | ||||
| @@ -210,5 +214,33 @@ namespace Core.Inventory.Application.UseCases.TagType | ||||
|                 ApiResponseHelper.EvaluatePort(ex, _port); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public async ValueTask ExecuteAsync(DeleteTagTypeRequest command, CancellationToken cancellationToken = default) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 ArgumentNullException.ThrowIfNull(command); | ||||
|  | ||||
|                 if (!command.IsValid(_deleteTagTypeValidator)) | ||||
|                 { | ||||
|                     _port.ValidationErrors(command.Notifications); | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 var result = await _inventoryServiceClient.DeleteTagTypeAsync(command.Id, cancellationToken).ConfigureAwait(false); | ||||
|  | ||||
|                 if (result == null) | ||||
|                 { | ||||
|                     _port.NoContentSuccess(); | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 _port.Success(result); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 ApiResponseHelper.EvaluatePort(ex, _port); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,13 @@ | ||||
| using Core.Inventory.Application.UseCases.TagType.Input; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace Core.Inventory.Application.UseCases.TagType.Validator | ||||
| { | ||||
|     public class DeleteTagTypeValidator : AbstractValidator<DeleteTagTypeRequest> | ||||
|     { | ||||
|         public DeleteTagTypeValidator() | ||||
|         { | ||||
|             RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("TagType Id").WithMessage("TagType Id is Obligatory."); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Oscar Morales
					Oscar Morales