Created ExpiringTECNWorker

This commit is contained in:
Chase Tucker
2024-03-29 15:01:39 -07:00
parent 830c8576e3
commit a86fbbbea0
5 changed files with 185 additions and 3 deletions

View File

@ -7,6 +7,7 @@ namespace FabApprovalWorkerService.Services;
public interface IECNService {
Task<IEnumerable<ECN>> GetExpiringTECNs();
Task<IEnumerable<ECN>> GetExpiredTECNs();
Task<IEnumerable<string>> GetTECNNotificationUserEmails();
}
public class ECNService : IECNService {
@ -75,4 +76,24 @@ public class ECNService : IECNService {
throw;
}
}
public async Task<IEnumerable<string>> GetTECNNotificationUserEmails() {
try {
_logger.LogInformation("Attempting to get TECN notification user emails");
string sql = "select u.Email from TECNNotificationsUsers t join Users u on t.UserId = u.UserID;";
IEnumerable<string> tecnNotificationUserEmails = (await _dalService.QueryAsync<string>(sql)).ToList();
_logger.LogInformation($"Found {tecnNotificationUserEmails.Count()} TECN notification user emails");
return tecnNotificationUserEmails;
} catch (Exception ex) {
StringBuilder errMsgBuilder = new();
errMsgBuilder.Append("An exception occurred when attempting to get TECN notification user emails. ");
errMsgBuilder.Append($"Exception: {ex.Message}");
_logger.LogError(errMsgBuilder.ToString());
throw;
}
}
}