using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using IceImportBLL.IceImportRun; using IceImportSL.Parameters.Run; using static GB5Shared.GB5Constant.Constant; namespace IceImportSL.Endpoints.Run; public class GetImportRunDetail : BaseEndpoint> { private readonly IIceImportRunBLL _runBll; public GetImportRunDetail(IIceImportRunBLL runBll) => _runBll = runBll; public override void Configure() { Get("/IceImport/GetImportRunDetail"); AllowAnonymous(); } protected override string? GetCacheKey(GetImportRunDetailParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( GetImportRunDetailParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _runBll.GetDetailAsync(req.RunId, login, ct).ConfigureAwait(false); if (result is null) return await GB5Shared.ResponseStandard.Response.CreateExceptionError( new InvalidOperationException($"IceImport run {req.RunId} not found."), CacheKeyLevel.NOT_REQUIRED, login, $"IceImport run {req.RunId} not found.", 404); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } }