using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using Microsoft.AspNetCore.Mvc; using RecruitmentBLL.JobPosition; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.JobPosition { public class DeleteJobPosition: BaseEndpoint> { private readonly IJobPositionBLL _JobPositionBLL; public DeleteJobPosition(IJobPositionBLL jobPositionBLL) { _JobPositionBLL = jobPositionBLL; } public override void Configure() { Delete("/JobPosition/DeleteJobPosition"); // 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 DeleteJobPositionParameters( [property: FastEndpoints.FromHeader] string Login, [property: QueryParam] int JobPositionId ); protected override string? GetCacheKey(DeleteJobPositionParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync(DeleteJobPositionParameters req,LoginDTO LoginDTO,CancellationToken ct) { try { var result = await _JobPositionBLL.DeleteJobPosition(req.JobPositionId, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result,CacheKeyLevel.USER_LEVEL,LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex,CacheKeyLevel.USER_LEVEL, LoginDTO,ex.Message,500); } } } }