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 { // Lists every skill profile row for one employee (all products/models/skills), // unlike GetEmployeeSkillProfile which also requires ProfileId/SkillId to narrow to one entry. public class GetEmployeeSkillListByEmployeeId : BaseEndpoint> { private readonly IEmployeeSkillProfileBLL _bll; public GetEmployeeSkillListByEmployeeId(IEmployeeSkillProfileBLL bll) { _bll = bll; } public override void Configure() { Get("/EmployeeSkillProfile/GetEmployeeSkillListByEmployeeId"); AllowAnonymous(); } public record GetEmployeeSkillListByEmployeeIdParameters( [property: FromHeader] string Login, [property: QueryParam] int EmployeeId ); protected override string? GetCacheKey(GetEmployeeSkillListByEmployeeIdParameters req, LoginDTO login) => $"Skill:EmpProfile:List:{login.ClientId}:{req.EmployeeId}"; protected override async Task> ExecuteAsync( GetEmployeeSkillListByEmployeeIdParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetByEmployeeId(req.EmployeeId, 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); } } } }