using FastEndpoints; using FrameworkBLL.Module; using FrameworkDAL.DTO.Project; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.Module { public class SaveModule : BaseEndpoint> { private readonly IModuleBLL _ModuleBLL; public SaveModule(IModuleBLL ModuleBLL) { _ModuleBLL = ModuleBLL; } public override void Configure() { Post("/Module/SaveModule"); AllowAnonymous(); } public record SaveModuleParameters( [property: FromHeader] string Login, [property: FromBody] ModuleDTO ModuleDTO ); protected override async Task> ExecuteAsync(SaveModuleParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _ModuleBLL.SaveModule(req.ModuleDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }