using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.Inspection; using System.Text.Json; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.Inspection { public class GetSelectListInspection : BaseEndpoint> { private readonly IInspectionBLL _bll; public GetSelectListInspection(IInspectionBLL bll) => _bll = bll; public override void Configure() { Post("/Inspection/GetSelectListInspection"); AllowAnonymous(); } public record GetSelectListInspectionParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override async Task> ExecuteAsync( GetSelectListInspectionParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _bll.GetPicklistInspection(req.CriteriaDTO, loginDTO!, ct); using var doc = JsonDocument.Parse(result); var parsed = doc.RootElement.Clone(); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(parsed, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, loginDTO, ex.Message, 500); } } } }