Added new endpoint for variants GetAll

This commit is contained in:
2025-06-27 18:02:24 -06:00
parent 24f647f90e
commit 0038169f5a
5 changed files with 51 additions and 6 deletions

View File

@@ -0,0 +1,14 @@
// ***********************************************************************
// <copyright file="GetAllFurnitureVariantRequest.cs">
// Core.Inventory
// </copyright>
// ***********************************************************************
using Lib.Architecture.BuildingBlocks;
namespace Core.Inventory.Application.UseCases.Inventory.Input.Variant
{
public class GetAllFurnitureVariantRequest : ICommand
{
public bool Validate() => true;
}
}

View File

@@ -23,7 +23,8 @@ namespace Core.Inventory.Application.UseCases.Inventory
IComponentHandler<GetFurnitureVariantByIdRequest>,
IComponentHandler<GetAllFurnitureVariantsByModelIdRequest>,
IComponentHandler<ChangeFurnitureVariantStatusRequest>,
IComponentHandler<GetFurnitureVariantsByIdsRequest>
IComponentHandler<GetFurnitureVariantsByIdsRequest>,
IComponentHandler<GetAllFurnitureVariantRequest>
{
// FurnitureBase
private readonly IFurnitureBasePort _basePort;
@@ -315,7 +316,7 @@ namespace Core.Inventory.Application.UseCases.Inventory
return;
}
var result = await _inventoryDALService.GetFurnitureVariantsByIdsAsync(command.Ids.ToArray());
var result = await _inventoryDALService.GetFurnitureVariantsByIdsAsync([.. command.Ids], cancellationToken);
if (result is null || !result.Any())
{
@@ -350,6 +351,24 @@ namespace Core.Inventory.Application.UseCases.Inventory
}
}
public async ValueTask ExecuteAsync(GetAllFurnitureVariantRequest command, CancellationToken cancellationToken = default)
{
try
{
var result = await _inventoryDALService.GetAllFurnitureVariantAsync(cancellationToken);
if (!result.Any())
{
_variantPort.NoContentSuccess();
return;
}
_variantPort.Success([.. result]);
}
catch (Exception ex)
{
ApiResponseHelper.EvaluatePort(ex, _basePort);
}
}
#endregion
}
}