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

@ -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;
}
}
}