using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using RecruitmentBLL.ProfileGenerator; using System; using System.Threading; using System.Threading.Tasks; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.ProfileGenerator { public class GetProfileGenerator : BaseEndpoint { private readonly IProfileGeneratorBLL _ProfileGeneratorBLL; public GetProfileGenerator(IProfileGeneratorBLL profileGeneratorBLL) { _ProfileGeneratorBLL = profileGeneratorBLL; } public override void Configure() { Get("/ProfileGenerator/GetProfileGenerator"); AllowAnonymous(); } public record GetProfileGeneratorParameters( [property: QueryParam] int ProfileGeneratorId, [property: FastEndpoints.FromHeader] string Login ); protected override string? GetCacheKey(GetProfileGeneratorParameters parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration( parameters.ProfileGeneratorId, EntityConstant.OBJECTRECRUITMENTPROFILEGENERATOR, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync( GetProfileGeneratorParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _ProfileGeneratorBLL .GetProfileGenerator(parameters.ProfileGeneratorId, loginDTO!, ct); 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); } } } }