Created ExpiringTECNWorker
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
using FabApprovalWorkerService.Models;
|
||||
|
||||
using NLog.Filters;
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace FabApprovalWorkerService.Services;
|
||||
@ -20,6 +18,7 @@ public interface IUserService {
|
||||
Task<bool> RemoveOOOFlagForUser(int userId);
|
||||
Task<bool> SetOOOTempProcessed(OOOTemp oOOTemp);
|
||||
Task<List<User>> GetAllExpiredOOOUsersAsync();
|
||||
Task<string> GetUserEmail(int userId);
|
||||
}
|
||||
|
||||
public class UserService : IUserService {
|
||||
@ -341,4 +340,27 @@ public class UserService : IUserService {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string> GetUserEmail(int userId) {
|
||||
try {
|
||||
if (userId <= 0) throw new ArgumentException($"User Id {userId} is not a valid user Id");
|
||||
|
||||
_logger.LogInformation($"Attempting to get email for user {userId}");
|
||||
|
||||
string sql = $"select Email from Users where UserID = {userId}";
|
||||
|
||||
string? userEmail = (await _dalService.QueryAsync<string>(sql)).ToList().FirstOrDefault();
|
||||
|
||||
if (userEmail is null)
|
||||
throw new Exception($"No email found for user {userId}");
|
||||
|
||||
return userEmail;
|
||||
} catch (Exception ex) {
|
||||
StringBuilder errMsgBuilder = new();
|
||||
errMsgBuilder.Append($"An exception occurred when attempting to get email for user {userId}. ");
|
||||
errMsgBuilder.Append($"Exception: {ex.Message}");
|
||||
_logger.LogError(errMsgBuilder.ToString());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user