Files
hrynco-notification-service/HrynCo.NotificationService.DAL.EF/Configurations/EmailChannelEntityConfiguration.cs
T
Anatolii Grynchuk b0996833bc feat: add RabbitMQ worker, contracts, usage UI in channels screen
- Add HrynCo.NotificationService.Contracts project with SendEmailMessage and NotificationResultMessage
- Add SendEmailConsumer (RabbitMQ worker) with reply-to pattern via CorrelationContext.ReplyTo
- Add SendEmailHandler owning SMTP send + usage increment as business logic
- Add GetChannelUsageSummaryHandler with single DB query via navigation property
- Merge usage stats inline into channels list (daily/monthly with progress bars)
- Refactor AdminChannelsController.Index to use GetChannelUsageSummaryQuery
- Add RabbitMQ service to docker-compose files
- Remove dead AdminChannelUsageController, ChannelUsageViewModel, ChannelUsageSummary

Ref: IT-628

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-02 14:00:58 +03:00

44 lines
1.6 KiB
C#

using HrynCo.NotificationService.DAL.EF.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace HrynCo.NotificationService.DAL.EF.Configurations;
internal class EmailChannelEntityConfiguration : IEntityTypeConfiguration<EmailChannelEntity>
{
public void Configure(EntityTypeBuilder<EmailChannelEntity> builder)
{
builder.ToTable("email_channels");
builder.HasKey(x => x.Id);
builder.Property(x => x.Id).HasColumnName("id");
builder.Property(x => x.ServiceName)
.HasColumnName("service_name")
.IsRequired()
.HasMaxLength(100);
builder.HasIndex(x => new { x.ServiceName, x.Priority });
builder.Property(x => x.Priority).HasColumnName("priority");
builder.Property(x => x.EmailChannelType).HasColumnName("provider_type");
builder.Property(x => x.SettingsJson)
.HasColumnName("settings")
.HasColumnType("jsonb")
.IsRequired();
builder.Property(x => x.DailyLimit).HasColumnName("daily_limit");
builder.Property(x => x.MonthlyLimit).HasColumnName("monthly_limit");
builder.Property(x => x.WarnThresholdPercent).HasColumnName("warn_threshold_percent");
builder.Property(x => x.IsActive).HasColumnName("is_active");
builder.Property(x => x.Created).HasColumnName("created");
builder.Property(x => x.Updated).HasColumnName("updated");
builder.HasMany(x => x.UsageRecords)
.WithOne()
.HasForeignKey(u => u.ProviderId);
}
}