using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.StockValuation; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.StockValuation { public class GetCostWorkings : BaseEndpoint> { private readonly IStockValuationBLL _bll; public GetCostWorkings(IStockValuationBLL bll) { _bll = bll; } public override void Configure() { Get("/StockValuation/GetCostWorkings"); AllowAnonymous(); } public record GetCostWorkingsParameters( [property: FromHeader] string Login, [property: QueryParam] int ItemId, [property: QueryParam] int SKUId, [property: QueryParam] int StoreId, [property: QueryParam] int OUID, [property: QueryParam] DateOnly AsOfDate ); protected override string? GetCacheKey(GetCostWorkingsParameters Parameters, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync( GetCostWorkingsParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _bll.GetCostWorkingsAsync( req.ItemId, req.SKUId, req.StoreId, req.OUID, req.AsOfDate, 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); } } } }