using FastEndpoints; using FrameworkBLL.Taxonomy; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Taxonomy.Course { public class GetSelectListCourse : BaseEndpoint> { private readonly ICourseBLL _CourseBLL; public GetSelectListCourse(ICourseBLL courseBLL) { _CourseBLL = courseBLL; } public override void Configure() { Post("/TaxonomyCourse/GetSelectListCourse"); AllowAnonymous(); } public record GetSelectListCourseParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override async Task> ExecuteAsync(GetSelectListCourseParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _CourseBLL.GetSelectListCourse(req.CriteriaDTO, loginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, loginDTO, ex.Message, 500); } } } }