using EnablementBLL.ShowRule; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace EnablementSL.Endpoints.ShowRule { // GetShowRuleList (the Show-authoring screen's list endpoint) ignores its ShowId // param and returns every TSHOWRULE row regardless of owner (pre-existing bug, // out of scope here) — now that TSHOWRULE is polymorphic (Show or Channel owned, // see V005 migration), reusing it for Channel rules would mix both owners // together in the FE grid. This is a separate, correctly-filtered endpoint for // the ShowChannelRule authoring screen instead. public class GetShowRuleListForChannel : BaseEndpoint> { private readonly IShowRuleBLL _showRuleBLL; public GetShowRuleListForChannel(IShowRuleBLL showRuleBLL) { _showRuleBLL = showRuleBLL; } public override void Configure() { Get("/Enablement/GetShowRuleListForChannel"); AllowAnonymous(); } public record GetShowRuleListForChannelParameters( [property: FromHeader] string Login, [property: QueryParam] int ChannelId ); protected override async Task> ExecuteAsync( GetShowRuleListForChannelParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _showRuleBLL.GetShowRulesForChannelAsync(req.ChannelId, 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); } } } }