using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using Microsoft.AspNetCore.Mvc; using RecruitmentBLL.JobProfileLibrary; using RecruitmentDAL.DTO.JobProfileLibrary; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.JobProfileLibrary { public class SaveJobProfileLibrary : BaseEndpoint> { private readonly IJobProfileLibraryBLL _JobProfileLibraryBLL; public SaveJobProfileLibrary(IJobProfileLibraryBLL jobProfileLibraryBLL) { _JobProfileLibraryBLL = jobProfileLibraryBLL; } public override void Configure() { Post("/JobProfileLibrary/SaveJobProfileLibrary"); // Roles("HR", "Recruiter") throws 500 here — no host in this repo configures // AddAuthentication (HRFinanceHost included; see PayRollSL's GetHRMSDashboard.cs // for the same documented, repo-wide gap). AllowAnonymous matches every other // endpoint in this SL module today. AllowAnonymous(); } public record SaveJobProfileLibraryParameters( [property: FastEndpoints.FromHeader] string Login, [property: FastEndpoints.FromBody] JobProfileLibraryDTO JobProfileLibraryDTO ); protected override string? GetCacheKey(SaveJobProfileLibraryParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( SaveJobProfileLibraryParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _JobProfileLibraryBLL .SaveJobProfileLibrary(req.JobProfileLibraryDTO, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }