feat: Implement Inventory Management Commands and Queries
Build and Deploy / build (push) Successful in 1m46s

- Added CreateWarehouseCommand and CreateWarehouseCommandHandler for warehouse creation.
- Introduced RecordLossCommand and RecordLossCommandHandler to handle stock loss recording.
- Created UpdateInventorySettingsCommand and its handler for updating inventory settings.
- Implemented GetAllInventoryItemsQuery and its handler to retrieve inventory items with pagination.
- Added GetAllWarehousesQuery and handler for fetching all warehouses.
- Developed GetLowStockItemsQuery and handler to get items below a specified stock threshold.
- Implemented GetStockMovementsQuery and handler for retrieving stock movement records.
- Created mappings for inventory-related requests and responses in InventoryProfile.
- Developed InventoryService to handle gRPC requests for inventory operations.
- Added Protobuf definitions for inventory management services and messages.
This commit is contained in:
masoodafar-web
2026-01-03 07:37:32 +03:30
parent 0c63b3c83c
commit f6f943947c
26 changed files with 1285 additions and 0 deletions
@@ -0,0 +1,37 @@
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.Note))
protoRequest.Reason = request.Note;
var response = await _context.Inventory.AdjustStockAsync(protoRequest, cancellationToken: cancellationToken);
return new AdjustStockResponseDto
{
Success = true,
OldQuantity = response.PreviousQuantity,
NewQuantity = response.NewQuantity,
Difference = response.Difference,
Message = "تعدیل موجودی با موفقیت انجام شد"
};
}
}