using FastEndpoints; using FrameworkBLL.Taxonomy; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Taxonomy.LearningObject { // Resolves the Learning Object (if any) that wraps a given source entity, e.g. "is this Quiz // already curated into a course?" — used by TMS/Enablement/WI when composing curriculum content. public class GetLearningObjectBySource : BaseEndpoint> { private readonly ILearningObjectBLL _LearningObjectBLL; public GetLearningObjectBySource(ILearningObjectBLL learningObjectBLL) { _LearningObjectBLL = learningObjectBLL; } public override void Configure() { Get("/TaxonomyLearningObject/GetLearningObjectBySource"); AllowAnonymous(); } public record GetLearningObjectBySourceParameters( [property: QueryParam] int LoType, [property: QueryParam] int SourceEntityId, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync(GetLearningObjectBySourceParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _LearningObjectBLL.GetLearningObjectBySource(req.LoType, req.SourceEntityId, loginDTO!); 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); } } } }