using AccountsBLL.CostCenter; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static AccountsSL.EndPoints.CostCategory.GetCostCategory; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.CostCenter { public class GetCostCenter : BaseEndpoint> { private readonly ICostCenterBLL _CostCenterBLL; public GetCostCenter(ICostCenterBLL costCenterBLL) { _CostCenterBLL = costCenterBLL; } public override void Configure() { Get("/CostCenter/GetCostCenter"); AllowAnonymous(); } public record GetCostCenterParameters( [property: FromHeader] string Login, [property: QueryParam] int CostCenterId ); //protected override string? GetCacheKey(GetCostCenterParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.CostCenterId, EntityConstant.OBJECTCOSTCENTER, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} //protected override string? GetCacheKey(GetCostCenterParameters req, LoginDTO login) //=> KeyGenerator.KeyGeneration(req.CostCenterId, EntityConstant.OBJECTCOSTCENTER, CacheKeyLevel.USER_LEVEL, login); protected override async Task> ExecuteAsync(GetCostCenterParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _CostCenterBLL.GetCostCenter(req.CostCenterId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, LoginDTO, ex.Message, 500); } } } }