using AccountsBLL.WarehouseFact; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.WarehouseFact { public class GetWarehouseFact : BaseEndpoint> { private readonly IWarehouseFactBLL _WarehouseFactBLL; public GetWarehouseFact(IWarehouseFactBLL WarehouseFactBLL) { _WarehouseFactBLL = WarehouseFactBLL; } public override void Configure() { Get("/Warehouse/GetWarehouseFact"); AllowAnonymous(); } public record GetWarehouseFactParameters( [property: FromHeader] string Login, [property: QueryParam] int FactId ); protected override string? GetCacheKey(GetWarehouseFactParameters Parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(Parameters.FactId, EntityConstant.OBJECTWAREHOUSEFACT, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetWarehouseFactParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _WarehouseFactBLL.GetWarehouseFact(req.FactId, 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); } } } }