using FastEndpoints; using FrameworkBLL.Taxonomy; using FrameworkDAL.DTO.Taxonomy; 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 SaveCourse : BaseEndpoint> { private readonly ICourseBLL _CourseBLL; public SaveCourse(ICourseBLL courseBLL) { _CourseBLL = courseBLL; } public override void Configure() { Post("/TaxonomyCourse/SaveCourse"); AllowAnonymous(); } public record SaveCourseParameters( [property: FromHeader] string Login, [property: FromBody] CourseDTO CourseDTO ); protected override async Task> ExecuteAsync(SaveCourseParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _CourseBLL.SaveCourse(req.CourseDTO, 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); } } } }