f027fd0b06
Build and Deploy / build (push) Failing after 2m12s
- Updated ProductType enum values to be more descriptive (RegularProduct, DiscountProduct). - Removed unnecessary Success and Message properties from response DTOs in AddStock and AdjustStock commands. - Renamed Note property to Reason in AdjustStock and RecordLoss commands, and added ReferenceNumber. - Changed InventoryItemId to Id in UpdateInventorySettingsCommand for consistency. - Updated pagination properties in various queries (PageIndex to Page). - Enhanced GetAllInventoryItemsQuery and GetLowStockItemsQuery to include sorting options. - Updated InventoryProfile mappings to reflect changes in DTOs and Protobuf definitions. - Adjusted Protobuf definitions to align with new property names and structures.
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using CMSMicroservice.Protobuf.Protos.Inventory;
|
|
|
|
namespace BackOffice.BFF.Application.InventoryCQ.Commands.AdjustStock;
|
|
|
|
public class AdjustStockCommandHandler : IRequestHandler<AdjustStockCommand, AdjustStockResponseDto>
|
|
{
|
|
private readonly IApplicationContractContext _context;
|
|
|
|
public AdjustStockCommandHandler(IApplicationContractContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<AdjustStockResponseDto> Handle(AdjustStockCommand request, CancellationToken cancellationToken)
|
|
{
|
|
var protoRequest = new AdjustStockRequest
|
|
{
|
|
ProductId = request.ProductId,
|
|
ProductType = (ProductType)request.ProductType,
|
|
NewQuantity = request.NewQuantity
|
|
};
|
|
|
|
if (!string.IsNullOrWhiteSpace(request.Reason))
|
|
protoRequest.Reason = request.Reason;
|
|
|
|
if (!string.IsNullOrWhiteSpace(request.ReferenceNumber))
|
|
protoRequest.ReferenceNumber = request.ReferenceNumber;
|
|
|
|
var response = await _context.Inventory.AdjustStockAsync(protoRequest, cancellationToken: cancellationToken);
|
|
|
|
return new AdjustStockResponseDto
|
|
{
|
|
PreviousQuantity = response.PreviousQuantity,
|
|
NewQuantity = response.NewQuantity,
|
|
Difference = response.Difference
|
|
};
|
|
}
|
|
}
|