25fb48ccf0
- Extract email template handling, rendering, and sending code into `Worker.Services` project. - Introduce `EmailTemplateService`, `EmailTemplateRenderingService`, and `SendEmailService`. - Simplify consumer logic by delegating to scoped services. - Update project dependencies and package references accordingly.
25 lines
804 B
C#
25 lines
804 B
C#
using HrynCo.NotificationService.DAL.EF;
|
|
using HrynCo.NotificationService.Worker;
|
|
using HrynCo.NotificationService.Worker.Services;
|
|
using Hrynco.RabbitMq;
|
|
|
|
var builder = Host.CreateApplicationBuilder(args);
|
|
|
|
builder.AddSerilog();
|
|
|
|
var appSettings = builder.Configuration
|
|
.GetSection(AppSettings.SectionName)
|
|
.Get<AppSettings>() ?? throw new InvalidOperationException("App settings are not configured.");
|
|
|
|
builder.Services.AddSingleton(appSettings);
|
|
builder.Services.AddNotificationDataAccess(appSettings.ConnectionString);
|
|
builder.Services.AddNotificationWorkerServices();
|
|
|
|
builder.Services.Configure<RabbitMqSettings>(
|
|
builder.Configuration.GetSection($"{AppSettings.SectionName}:RabbitMq"));
|
|
|
|
builder.Services.AddHostedService<SendEmailConsumer>();
|
|
|
|
var host = builder.Build();
|
|
host.Run();
|