using AccountsBLL.WarehousePostingRule; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.WarehousePostingRule { // Lists posting rules, optionally filtered to one FactId (e.g. all rules for FFINANCE) — the // admin-UI grid backing GetWarehousePostingRule (single-row) above. public class GetWarehousePostingRuleList : BaseEndpoint> { private readonly IWarehousePostingRuleBLL _WarehousePostingRuleBLL; public GetWarehousePostingRuleList(IWarehousePostingRuleBLL WarehousePostingRuleBLL) { _WarehousePostingRuleBLL = WarehousePostingRuleBLL; } public override void Configure() { Get("/Warehouse/GetWarehousePostingRuleList"); AllowAnonymous(); } public record GetWarehousePostingRuleListParameters( [property: FromHeader] string Login, [property: QueryParam] int? FactId ); protected override async Task> ExecuteAsync(GetWarehousePostingRuleListParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _WarehousePostingRuleBLL.GetWarehousePostingRuleList(req.FactId, LoginDTO!); 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); } } } }