using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.Specification; using MMDAL.DTO.Specification; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.Specification { public class SaveSpecification : BaseEndpoint { private readonly ISpecificationBLL _SpecificationBLL; public SaveSpecification(ISpecificationBLL SpecificationBLL) { _SpecificationBLL = SpecificationBLL; } public override void Configure() { Post("/Specification/SaveSpecification"); AllowAnonymous(); } public record SaveSpecificationParameters( [property: FromBody] SpecificationDTO SpecificationDTO, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync(SaveSpecificationParameters parameters, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _SpecificationBLL.SaveSpecification(parameters.SpecificationDTO, 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); } } } }