using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.InspectionArea; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.InspectionArea { public class GetInspectionArea : BaseEndpoint> { private readonly IInspectionAreaBLL _InspectionAreaBLL; public GetInspectionArea(IInspectionAreaBLL IInspectionAreaBLL) { _InspectionAreaBLL = IInspectionAreaBLL; } public override void Configure() { Get("/InspectionArea/GetInspectionArea"); AllowAnonymous(); } public record GetInspectionAreaParameters( [property: QueryParam] int InspectionAreaId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetInspectionAreaParameters GetInspectionAreaParameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(GetInspectionAreaParameters.InspectionAreaId!, EntityConstant.OBJECTINSPECTIONAREA, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetInspectionAreaParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _InspectionAreaBLL.GetInspectionArea(req.InspectionAreaId, 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); } } } }