using EntitlementBLL.Demo; using EntitlementDAL.DTOs; using FastEndpoints; using GB5Shared.Authorization; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace EntitlementSL.Endpoints.Demo; // Internal (ops/CS) catalog authoring — registers one new demo "flavor" (industry x geography x // period, or a specific feature showcase). Previously only reachable via direct SQL (tracker // §49's own "explicitly NOT built yet" item 3). Create-only for now — no update path exists in // DemoDAL yet (VARIANT_INSERT is the only write); a real edit flow is a small follow-up. [MenuRights("entdemo", RightOperation.Insert)] public class SaveDemoVariant : BaseEndpoint> { private readonly IDemoCatalogBLL _DemoCatalogBLL; public SaveDemoVariant(IDemoCatalogBLL demoCatalogBLL) => _DemoCatalogBLL = demoCatalogBLL; public override void Configure() { Post("/Demo/SaveDemoVariant"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: FromBody] DemoVariantDTO DemoVariantDTO ); protected override string? GetCacheKey(Params req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(Params req, LoginDTO loginDTO, CancellationToken ct) { var result = await _DemoCatalogBLL.CreateVariantAsync(req.DemoVariantDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } }