using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using RecruitmentBLL.InternalMobility; using RecruitmentDAL.DTO.InternalMobility; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.InternalMobility { // Internal mobility apply flow (Phase 6) — the internally-authenticated-context counterpart // to RecruitmentSL.EndPoints.Career.SubmitApplication. A distinct route so an existing // employee applying to a different internal opening never goes through the public // career-site apply endpoint (see RecruitmentBLL.Career.CareerBLL.SubmitApplication's own // InternalEmployee-CandidateType guard for the matching half of that separation). // // This module has no working Roles()/session auth anywhere yet (see CLAUDE.md's // "AllowAnonymous() everywhere" note) — "internally authenticated" here means what CLAUDE.md // says it means for this module today: a distinct endpoint intended for logged-in-employee // use, not the public career site, rather than a genuinely enforced auth boundary. No // Throttle() here (unlike the public SubmitApplication) — this is not reachable by an // anonymous internet visitor. public class SubmitInternalApplication : BaseEndpoint> { private readonly IInternalMobilityBLL _InternalMobilityBLL; public SubmitInternalApplication(IInternalMobilityBLL internalMobilityBLL) { _InternalMobilityBLL = internalMobilityBLL; } public override void Configure() { Post("/InternalMobility/SubmitInternalApplication"); AllowAnonymous(); } public record SubmitInternalApplicationParameters( [property: FastEndpoints.FromHeader] string Login, [property: FastEndpoints.FromBody] InternalApplicationSubmissionDTO Submission ); // Mutation — never cached. protected override string? GetCacheKey(SubmitInternalApplicationParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( SubmitInternalApplicationParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _InternalMobilityBLL .SubmitInternalApplication(req.Submission, 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); } } } }