using FastEndpoints; using FrameworkBLL.GBPeriod; using FrameworkDAL.DTO.GBPeriod; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.EndPoints.GBPeriod { public class SaveGBPeriod : BaseEndpoint> { private readonly IGBPeriodBLL _GBPeriodBLL; public SaveGBPeriod(IGBPeriodBLL GBPeriodBLL) { _GBPeriodBLL = GBPeriodBLL; } public override void Configure() { Post("/GBPeriod/SaveGBPeriod"); AllowAnonymous(); } public record SaveGBPeriodParameters( [property: FromHeader] string Login, [property: FromBody] GBPeriodDTO GBPeriodDTO ); protected override async Task> ExecuteAsync(SaveGBPeriodParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _GBPeriodBLL.SaveGBPeriod(req.GBPeriodDTO, 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 ); } } } }