Files
BackOffice.BFF/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetLowStockItems/GetLowStockItemsQueryHandler.cs
T
masoodafar-web f027fd0b06
Build and Deploy / build (push) Failing after 2m12s
Refactor inventory commands and queries for improved clarity and consistency
- 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.
2026-01-03 15:38:22 +03:30

55 lines
2.0 KiB
C#

using BackOffice.BFF.Application.InventoryCQ.Queries.GetAllInventoryItems;
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 = request.Page,
PageSize = request.PageSize
};
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 GetAllInventoryItems.InventoryItemDto
{
Id = i.Id,
ProductId = i.ProductId,
DiscountProductId = i.DiscountProductId,
ProductType = (int)i.ProductType,
ProductTitle = i.ProductTitle,
ProductPrice = i.ProductPrice,
Quantity = i.Quantity,
ReservedQuantity = i.ReservedQuantity,
AvailableQuantity = i.AvailableQuantity,
LowStockThreshold = i.LowStockThreshold,
ReorderPoint = i.ReorderPoint,
MaxStockLevel = i.MaxStockLevel,
WarehouseId = i.WarehouseId,
WarehouseName = i.WarehouseName,
IsLowStock = true
}).ToList()
};
}
}