Align .editorconfig files

When debugging only
app.Services.GetRequiredService<IPCRBService>();

Injected AppSettings instead of using GetEnvironmentVariable at Services level

Get ready to use VSCode IDE
This commit is contained in:
2024-12-03 12:23:56 -07:00
parent 89790f4fc1
commit 538b1f817e
72 changed files with 3420 additions and 391 deletions

View File

@ -1,9 +1,10 @@
using MesaFabApproval.API.Clients;
using System.Net.Mail;
using MesaFabApproval.API.Clients;
using MesaFabApproval.Models;
using Microsoft.IdentityModel.Tokens;
using System.Net.Mail;
namespace MesaFabApproval.API.Services;
public interface ISmtpService {
@ -15,13 +16,12 @@ public class SmtpService : ISmtpService {
private readonly ISmtpClientWrapper _smtpClient;
private readonly bool _shouldSendEmail;
public SmtpService(ILogger<SmtpService> logger, ISmtpClientWrapper smtpClient) {
public SmtpService(ILogger<SmtpService> logger, ISmtpClientWrapper smtpClient, AppSettings appSettings) {
_logger = logger ??
throw new ArgumentNullException("ILogger not injected");
_smtpClient = smtpClient ??
throw new ArgumentNullException("SmtpClient not injected");
if (!Boolean.TryParse(Environment.GetEnvironmentVariable("FabApprovalShouldSendEmail"), out _shouldSendEmail))
throw new ArgumentNullException("FabApprovalShouldSendEmail environment variable not found");
_shouldSendEmail = appSettings.ShouldSendEmail;
}
public async Task<bool> SendEmail(IEnumerable<MailAddress> recipients,
@ -32,7 +32,7 @@ public class SmtpService : ISmtpService {
if (ccRecipients is null) throw new ArgumentNullException("ccRecipients cannot be null!");
if (subject.IsNullOrEmpty()) throw new ArgumentNullException("subject cannot be null or empty!");
if (body.IsNullOrEmpty()) throw new ArgumentNullException("body cannot be null or empty!");
return await Task.Run(() => {
int maxRetries = 3;
int backoffSeconds = 30;
@ -76,4 +76,4 @@ public class SmtpService : ISmtpService {
return messageWasSent;
});
}
}
}