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