using FastEndpoints; using FrameworkBLL.Promotion; using FrameworkDAL.DTO.Promotion; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Promotion { // TODO: gate with [MenuRights] once a real menu row exists for this admin screen — this writes // a counterparty's public key, which is genuinely security-sensitive to leave ungated long-term. public class SavePromotionCounterparty : BaseEndpoint> { private readonly IPromotionCounterpartyBLL _BLL; public SavePromotionCounterparty(IPromotionCounterpartyBLL bll) => _BLL = bll; public override void Configure() { Post("/PromotionCounterparty/SavePromotionCounterparty"); AllowAnonymous(); } public record Parameters( [property: FromHeader] string Login, [property: FromBody] PromotionCounterpartyDTO Body ); protected override string? GetCacheKey(Parameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync(Parameters req, LoginDTO login, CancellationToken ct) { var result = await _BLL.SavePromotionCounterparty(req.Body, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, login); } } }