Added training reminder worker
This commit is contained in:
@ -19,6 +19,7 @@ public interface IUserService {
|
||||
Task<bool> SetOOOTempProcessed(OOOTemp oOOTemp);
|
||||
Task<List<User>> GetAllExpiredOOOUsersAsync();
|
||||
Task<string> GetUserEmail(int userId);
|
||||
Task<User> GetUserById(int userId);
|
||||
}
|
||||
|
||||
public class UserService : IUserService {
|
||||
@ -355,7 +356,7 @@ public class UserService : IUserService {
|
||||
|
||||
string sql = $"select Email from Users where UserID = {userId}";
|
||||
|
||||
string? userEmail = (await _dalService.QueryAsync<string>(sql)).ToList().FirstOrDefault();
|
||||
string? userEmail = (await _dalService.QueryAsync<string>(sql)).FirstOrDefault();
|
||||
|
||||
if (userEmail is null)
|
||||
throw new Exception($"No email found for user {userId}");
|
||||
@ -369,4 +370,27 @@ public class UserService : IUserService {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<User> GetUserById(int userId) {
|
||||
if (userId <= 0) throw new ArgumentException($"{userId} not a valid UserID");
|
||||
|
||||
try {
|
||||
_logger.LogInformation($"Attempting to get user {userId}");
|
||||
|
||||
string sql = $"select * from Users where UserID = {userId}";
|
||||
|
||||
User? user = (await _dalService.QueryAsync<User>(sql)).FirstOrDefault();
|
||||
|
||||
if (user is null)
|
||||
throw new Exception($"No user found for id {userId}");
|
||||
|
||||
return user;
|
||||
} 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