Created ECN# autocomplete for PCR3 docs

This commit is contained in:
Chase Tucker
2025-01-23 07:44:12 -07:00
parent c4036471f7
commit 6a2bc0b4ab
6 changed files with 101 additions and 13 deletions

View File

@ -53,4 +53,36 @@ public class ECNController : ControllerBase {
}
}
}
[HttpGet]
[Route("ecn/allNumbers")]
public async Task<IActionResult> GetAllECNNumbers() {
DateTime start = DateTime.Now;
bool isInternalError = false;
string errorMessage = "";
try {
_logger.LogInformation($"Attempting to get all ECN#s");
IEnumerable<int> allEcnNumbers = await _ecnService.GetAllECNNumbers();
return Ok(allEcnNumbers);
} catch (Exception ex) {
isInternalError = true;
errorMessage = $"Cannot get all ECN#s, because {ex.Message}";
return Problem(errorMessage);
} finally {
string metricName = "GetAllECNNumbers";
DateTime end = DateTime.Now;
double millisecondsDiff = (end - start).TotalMilliseconds;
_monInClient.PostAverage(metricName + "Latency", millisecondsDiff);
if (isInternalError) {
_logger.LogError(errorMessage);
_monInClient.PostStatus(metricName, StatusValue.Critical);
} else {
_monInClient.PostStatus(metricName, StatusValue.Ok);
}
}
}
}

View File

@ -265,6 +265,7 @@ public class PCRBController : ControllerBase {
[HttpPost]
[Route("pcrb/attachment")]
[ApiExplorerSettings(IgnoreApi = true)]
public async Task<IActionResult> UploadAttachment([FromForm] IFormFile file, [FromForm] PCRBAttachment attachment) {
DateTime start = DateTime.Now;
bool isArgumentError = false;

View File

@ -132,9 +132,6 @@ builder.Services.AddSwaggerGen(c => {
WebApplication app = builder.Build();
if (Debugger.IsAttached)
app.Services.GetRequiredService<IApprovalService>();
app.UseCors();
// Configure the HTTP request pipeline.

View File

@ -4,6 +4,7 @@ namespace MesaFabApproval.API.Services;
public interface IECNService {
Task<bool> IsValidECNNumber(int number);
Task<IEnumerable<int>> GetAllECNNumbers();
}
public class ECNService : IECNService {
@ -43,4 +44,19 @@ public class ECNService : IECNService {
throw;
}
}
public async Task<IEnumerable<int>> GetAllECNNumbers() {
try {
_logger.LogInformation("Attempting to get all ECN#s");
string sql = "select ECNNumber from ECN where Deleted=0 and Cancelled=0";
IEnumerable<int> allEcnNumbers = await _dalService.QueryAsync<int>(sql);
return allEcnNumbers;
} catch (Exception ex) {
_logger.LogError($"Unable to get all ECN#s, because {ex.Message}");
throw;
}
}
}