using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.FifoLayerCost; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.StockValuation { public class GetCostLayers : BaseEndpoint> { private readonly IFifoLayerCostBLL _bll; public GetCostLayers(IFifoLayerCostBLL bll) { _bll = bll; } public override void Configure() { Get("/StockValuation/GetCostLayers"); AllowAnonymous(); } public record GetCostLayersParameters( [property: FromHeader] string Login, [property: QueryParam] int ItemId, [property: QueryParam] int SKUId, [property: QueryParam] int StoreId, [property: QueryParam] int OUID ); protected override string? GetCacheKey(GetCostLayersParameters Parameters, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync( GetCostLayersParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _bll.GetOpenCostLayersAsync( req.ItemId, req.SKUId, req.StoreId, req.OUID, LoginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }