using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using Microsoft.AspNetCore.Mvc; using RecruitmentBLL.JobOffer; using RecruitmentDAL.DTO.JobOffer; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.JobOffer { public class SaveJobOffer : BaseEndpoint> { private readonly IJobOfferBLL _JobOfferBLL; public SaveJobOffer(IJobOfferBLL jobOfferBLL) { _JobOfferBLL = jobOfferBLL; } public override void Configure() { Post("/JobOffer/SaveJobOffer"); // Roles("User") throws 500 here — no host in this repo configures AddAuthentication, // so FastEndpoints has no scheme to challenge against (repo-wide gap, not specific to // this endpoint — see PayRollSL/EndPoints/Employee/GetHRMSDashboard.cs for the same // documented finding). AllowAnonymous matches every other endpoint in this SL module. AllowAnonymous(); } public record SaveJobOfferParameters( [property: FastEndpoints.FromHeader] string Login, [property: FastEndpoints.FromBody] JobOfferDTO JobOfferDTO ); // Mutation endpoint — never cached. protected override string? GetCacheKey(SaveJobOfferParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( SaveJobOfferParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _JobOfferBLL.SaveJobOffer(req.JobOfferDTO, 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); } } } }