using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.Inspection; using MMDAL.DTO.Inspection; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.Inspection { public class SaveInspection : BaseEndpoint> { private readonly IInspectionBLL _InspectionBLL; public SaveInspection(IInspectionBLL InspectionBLL) { _InspectionBLL = InspectionBLL; } public override void Configure() { Post("/Inspection/SaveInspection"); AllowAnonymous(); } public record SaveInspectionParameters( [property: FromHeader] string Login, [property: FromBody] InspectionDTO InspectionDTO ); protected override async Task> ExecuteAsync(SaveInspectionParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _InspectionBLL.SaveInspection(req.InspectionDTO, 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); } } } }