using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using SkillManagementBLL.EmployeeSkillProfile; using static GB5Shared.GB5Constant.Constant; namespace SkillManagementSL.EndPoints.EmployeeSkillProfile { public class GetEmployeeSkillProfile : BaseEndpoint> { private readonly IEmployeeSkillProfileBLL _bll; public GetEmployeeSkillProfile(IEmployeeSkillProfileBLL bll) { _bll = bll; } public override void Configure() { Get("/EmployeeSkillProfile/GetEmployeeSkillProfile"); AllowAnonymous(); } public record GetEmployeeSkillProfileParameters( [property: FromHeader] string Login, [property: QueryParam] int EmployeeId, [property: QueryParam] int ProfileId, [property: QueryParam] int SkillId ); protected override string? GetCacheKey(GetEmployeeSkillProfileParameters req, LoginDTO login) { try { return $"Skill:EmpProfile:{login.ClientId}:{req.EmployeeId}:{req.ProfileId}:{req.SkillId}"; } catch (Exception) { throw; } } protected override async Task> ExecuteAsync( GetEmployeeSkillProfileParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetByEmployee(req.EmployeeId,req.ProfileId,req.SkillId, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, login, ex.Message, 500); } } } }