using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using RecruitmentBLL.CandidatePortal; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.CandidatePortal { // Anonymous — no account exists yet, so there is nothing to authenticate against (same // posture as DXPSL.Endpoints.Auth.Register). Thin passthrough to DXP's real // /DXP/Auth/Register via ICandidatePortalBLL.RegisterAsync // (RecruitmentBLL.Integration.IDxpAuthIntegrationService). public class Register : BaseEndpoint> { private readonly ICandidatePortalBLL _BLL; public Register(ICandidatePortalBLL bll) => _BLL = bll; public record RegisterBody(string FullName, string Email, string? Mobile, string Password); public record RegisterParameters( [property: FromHeader] string Login, [property: FromBody] RegisterBody Body ); public override void Configure() { Post("/CandidatePortal/Register"); AllowAnonymous(); } protected override string? GetCacheKey(RegisterParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( RegisterParameters req, LoginDTO login, CancellationToken ct) { try { var message = await _BLL.RegisterAsync( req.Body.FullName, req.Body.Email, req.Body.Mobile, req.Body.Password, login, ct) .ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( message, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 400); } } } }