using System.Threading; using System.Threading.Tasks; using FastEndpoints; using FrameworkBLL.Promotion; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.Promotion { // ============================================================ // ProvisionPromotionIngestFlow — one-time (idempotent) admin setup action. // Creates + publishes the "PromotionIngest" GOP flow and its source binding // if not already present on this deployment. Safe to call repeatedly. // // TODO: gate behind real MenuRights once a menu row exists for this action // — AllowAnonymous() here matches every other endpoint built so far in this // module, pending that. // ============================================================ public class ProvisionPromotionIngestFlow : BaseEndpoint< ProvisionPromotionIngestFlow.ProvisionPromotionIngestFlowParameters, ResponseStandardDTO> { private readonly IPromotionFlowProvisioningBLL _ProvisioningBLL; public ProvisionPromotionIngestFlow(IPromotionFlowProvisioningBLL provisioningBLL) => _ProvisioningBLL = provisioningBLL; public override void Configure() { Post("/Promotion/ProvisionIngestFlow"); AllowAnonymous(); } public record ProvisionPromotionIngestFlowParameters( [property: FromHeader] string Login ); protected override async Task> ExecuteAsync( ProvisionPromotionIngestFlowParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _ProvisioningBLL.EnsureIngestFlowProvisionedAsync(LoginDTO, ct) .ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (System.Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }