using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.GradeStandard; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.GradeStandard { public class GetGradeStandard : BaseEndpoint> { private readonly IGradeStandardBLL _GradeStandardBLL; public GetGradeStandard(IGradeStandardBLL IGradeStandardBLL) { _GradeStandardBLL = IGradeStandardBLL; } public override void Configure() { Get("/GradeStandard/GetGradeStandard"); AllowAnonymous(); } public record GetGradeStandardParameters( [property: FromHeader] string Login, [property: QueryParam] int GradeStandardId ); //protected override string? GetCacheKey(GetGradeStandardParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.GradeStandardId!, EntityConstant.OBJECTGRADESTANDARD, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetGradeStandardParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _GradeStandardBLL.GetGradeStandard(req.GradeStandardId, 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); } } } }