using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.BOM; using static GB5Shared.GB5Constant.Constant; namespace MMSL.Endpoints.BOM { public class GetBOM : BaseEndpoint { private readonly IBOMBLL _BOMBLL; public GetBOM(IBOMBLL BOMBLL) { _BOMBLL = BOMBLL; } public override void Configure() { Get("/BOM/GetBOM"); AllowAnonymous(); } public record GetBOMParameters( [property: QueryParam] int BOMId, [property: FromHeader] string Login ); //protected override string? GetCacheKey(GetBOMParameters GetBOMParameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration( // GetBOMParameters.BOMId, // EntityConstant.OBJECTBOM, // CacheKeyLevel.USER_LEVEL, // LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync( GetBOMParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _BOMBLL.GetBOM(req.BOMId, LoginDTO!); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse(result, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError( ex, CacheKeyLevel.USER_LEVEL, LoginDTO, ex.Message, 500); } } } }