using AccountsBLL.CostCategory; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static AccountsSL.EndPoints.AccountGroup.GetAccountGroup; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.CostCategory { public class GetCostCategory : BaseEndpoint> { private readonly ICostCategoryBLL _CostCategoryBLL; public GetCostCategory(ICostCategoryBLL ICostCategoryBLL) { _CostCategoryBLL = ICostCategoryBLL; } public override void Configure() { Get("/CostCategory/GetCostCategory"); AllowAnonymous(); } public record GetCostCategoryParameters( [property: FromHeader] string Login, [property: QueryParam] int CostCategoryId ); //protected override string? GetCacheKey(GetCostCategoryParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.CostCategoryId!, EntityConstant.OBJECTCOSTCATEGORY, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} //protected override string? GetCacheKey(GetCostCategoryParameters req, LoginDTO login) // => KeyGenerator.KeyGeneration(req.CostCategoryId, EntityConstant.OBJECTCOSTCATEGORY, CacheKeyLevel.USER_LEVEL, login); protected override async Task> ExecuteAsync(GetCostCategoryParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _CostCategoryBLL.GetCostCategory(req.CostCategoryId, 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); } } } }