using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using Microsoft.AspNetCore.Mvc; using RecruitmentBLL.ProfileGenerator; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.ProfileGenerator { public class GetSelectListProfileGenerator : BaseEndpoint< GetSelectListProfileGenerator.GetSelectListProfileGeneratorParameters, ResponseStandardDTO> { private readonly IProfileGeneratorBLL _ProfileGeneratorBLL; public GetSelectListProfileGenerator(IProfileGeneratorBLL profileGeneratorBLL) { _ProfileGeneratorBLL = profileGeneratorBLL; } public override void Configure() { Post("/ProfileGenerator/GetSelectListProfileGenerator"); AllowAnonymous(); } public record GetSelectListProfileGeneratorParameters( [property: FastEndpoints.FromHeader] string Login, [property: FastEndpoints.FromBody] CriteriaDTO CriteriaDTO ); protected override string? GetCacheKey(GetSelectListProfileGeneratorParameters req, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration( -1, EntityConstant.OBJECTRECRUITMENTPROFILEGENERATOR, CacheKeyLevel.CLIENT_LEVEL, LoginDTO, req.CriteriaDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync( GetSelectListProfileGeneratorParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _ProfileGeneratorBLL .GetSelectListProfileGenerator(req.CriteriaDTO, 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); } } } }