using AccountsBLL.CostCenterPattern; 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.CostCenterPattern { public class GetCostCenterPattern : BaseEndpoint> { private readonly ICostCenterPatternBLL _CostCenterPatternBLL; public GetCostCenterPattern(ICostCenterPatternBLL costCenterPatternBLL) { _CostCenterPatternBLL = costCenterPatternBLL; } public override void Configure() { Get("/CostCenterPattern/GetCostCenterPattern"); AllowAnonymous(); } public record GetCostCenterPatternParameters( [property: FromHeader] string Login, [property: QueryParam] int CostCenterPatternId ); //protected override string? GetCacheKey(GetCostCenterPatternParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.CostCenterPatternId, EntityConstant.OBJECTCOSTCENTERPATTERN, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} // protected override string? GetCacheKey(GetCostCenterPatternParameters req, LoginDTO login) //=> KeyGenerator.KeyGeneration(req.CostCenterPatternId, EntityConstant.OBJECTCOSTCENTERPATTERN, CacheKeyLevel.USER_LEVEL, login); protected override async Task> ExecuteAsync(GetCostCenterPatternParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _CostCenterPatternBLL.GetCostCenterPattern(req.CostCenterPatternId, 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); } } } }