using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.DAPointGroup; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.DAPointGroup { public class GetDAPointGroup : BaseEndpoint { private readonly IDAPointGroupBLL _DAPointGroupBLL; public GetDAPointGroup(IDAPointGroupBLL IDAPointGroupBLL) { _DAPointGroupBLL = IDAPointGroupBLL; } public override void Configure() { Get("/DAPointGroup/GetDAPointGroup"); AllowAnonymous(); } public record GetDAPointGroupParameters( [property: QueryParam] int DAPointGroupId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetDAPointGroupParameters GetDAPointGroupParameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(GetDAPointGroupParameters.DAPointGroupId!, EntityConstant.OBJECTDAPOINTGROUP, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetDAPointGroupParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _DAPointGroupBLL.GetDAPointGroup(req.DAPointGroupId, 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); } } } }