feat: Implement Inventory Management Commands and Queries
Build and Deploy / build (push) Successful in 1m46s
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:
+50
@@ -0,0 +1,50 @@
|
||||
using CMSMicroservice.Protobuf.Protos.Inventory;
|
||||
|
||||
namespace BackOffice.BFF.Application.InventoryCQ.Queries.GetLowStockItems;
|
||||
|
||||
public class GetLowStockItemsQueryHandler : IRequestHandler<GetLowStockItemsQuery, GetLowStockItemsResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetLowStockItemsQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetLowStockItemsResponseDto> Handle(GetLowStockItemsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var protoRequest = new GetLowStockItemsRequest
|
||||
{
|
||||
Page = 1,
|
||||
PageSize = request.Count
|
||||
};
|
||||
|
||||
if (request.WarehouseId.HasValue)
|
||||
protoRequest.WarehouseId = request.WarehouseId.Value;
|
||||
|
||||
if (request.ProductType.HasValue)
|
||||
protoRequest.ProductType = (ProductType)request.ProductType.Value;
|
||||
|
||||
var response = await _context.Inventory.GetLowStockItemsAsync(protoRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return new GetLowStockItemsResponseDto
|
||||
{
|
||||
TotalCount = response.TotalCount,
|
||||
Items = response.Items.Select(i => new LowStockItemDto
|
||||
{
|
||||
Id = i.Id,
|
||||
ProductId = i.ProductId,
|
||||
DiscountProductId = i.DiscountProductId,
|
||||
ProductType = (int)i.ProductType,
|
||||
ProductName = i.ProductTitle,
|
||||
Quantity = i.Quantity,
|
||||
ReservedQuantity = i.ReservedQuantity,
|
||||
AvailableQuantity = i.AvailableQuantity,
|
||||
LowStockThreshold = i.LowStockThreshold,
|
||||
ReorderPoint = i.ReorderPoint,
|
||||
WarehouseId = i.WarehouseId,
|
||||
WarehouseName = i.WarehouseName
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user