using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.Inspection; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.Inspection { public class GetInspection : BaseEndpoint> { private readonly IInspectionBLL _InspectionBLL; public GetInspection(IInspectionBLL IInspectionBLL) { _InspectionBLL = IInspectionBLL; } public override void Configure() { Get("/Inspection/GetInspection"); AllowAnonymous(); } public record GetInspectionParameters( [property: FromHeader] string Login, [property: QueryParam] int InspectionId ); //protected override string? GetCacheKey(GetInspectionParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.SpaceInspectionId!, EntityConstant.OBJECTINSPECTION, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetInspectionParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _InspectionBLL.GetInspection(req.InspectionId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, LoginDTO, ex.Message, 500); } } } }