using CRMBLL.SLA; using CRMDAL.DTO.SLA; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace CRMSL.EndPoints.SLA { public class SaveSLA : BaseEndpoint { private readonly ISLABLL _SLABLL; public SaveSLA(ISLABLL SLABLL) { _SLABLL = SLABLL; } public override void Configure() { Post("/SLA/SaveSLA"); AllowAnonymous(); } public record SaveSLAParameters( [property: FromBody] SLADTO SLADTO, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync(SaveSLAParameters parameters,LoginDTO LoginDTO,CancellationToken ct) { try { var result = await _SLABLL.SaveSLA(parameters.SLADTO, 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); } } } }