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 { public class GetWarehousePostingRule : BaseEndpoint> { private readonly IWarehousePostingRuleBLL _WarehousePostingRuleBLL; public GetWarehousePostingRule(IWarehousePostingRuleBLL WarehousePostingRuleBLL) { _WarehousePostingRuleBLL = WarehousePostingRuleBLL; } public override void Configure() { Get("/Warehouse/GetWarehousePostingRule"); AllowAnonymous(); } public record GetWarehousePostingRuleParameters( [property: FromHeader] string Login, [property: QueryParam] int PostingRuleId ); protected override string? GetCacheKey(GetWarehousePostingRuleParameters Parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(Parameters.PostingRuleId, EntityConstant.OBJECTWAREHOUSEPOSTINGRULE, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetWarehousePostingRuleParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _WarehousePostingRuleBLL.GetWarehousePostingRule(req.PostingRuleId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, LoginDTO, ex.Message, 500); } } } }