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>
This commit is contained in:
Anatolii Grynchuk
2026-05-02 14:00:58 +03:00
parent 395f5573a1
commit b0996833bc
29 changed files with 569 additions and 78 deletions
@@ -1,5 +1,5 @@
@using HrynCo.NotificationService.DAL.Abstract.Providers
@model IReadOnlyList<EmailChannel>
@using HrynCo.NotificationService.Services.EmailChannels.GetUsageSummary
@model IReadOnlyList<ChannelUsageEntry>
@{
ViewData["Title"] = "Email Channels";
}
@@ -40,12 +40,12 @@ else
<table class="table table-hover table-sm mb-0">
<thead class="table-dark">
<tr>
<th>Service Name</th>
<th>Service</th>
<th>Type</th>
<th>Priority</th>
<th>Status</th>
<th>Daily Limit</th>
<th>Monthly Limit</th>
<th>Today</th>
<th>This Month</th>
<th class="text-end">Actions</th>
</tr>
</thead>
@@ -54,7 +54,7 @@ else
{
<tr>
<td>@c.ServiceName</td>
<td>@c.EmailChannelType</td>
<td>@c.ChannelType</td>
<td>@c.Priority</td>
<td>
@if (c.IsActive)
@@ -66,15 +66,53 @@ else
<span class="badge bg-secondary text-muted">Inactive</span>
}
</td>
<td>@(c.DailyLimit.HasValue ? c.DailyLimit.ToString() : "—")</td>
<td>@(c.MonthlyLimit.HasValue ? c.MonthlyLimit.ToString() : "—")</td>
<td style="min-width:130px">
@{
var dailyLabel = c.DailyLimit.HasValue ? $"{c.DailySent} / {c.DailyLimit}" : c.DailySent.ToString();
}
@if (c.DailyLimit.HasValue && c.DailyLimit > 0)
{
var pct = Math.Min((double)c.DailySent / c.DailyLimit.Value * 100, 100);
var color = pct >= 100 ? "danger" : pct >= 90 ? "warning" : "success";
<div class="d-flex align-items-center gap-2">
<div class="progress flex-grow-1" style="height:6px; min-width:60px">
<div class="progress-bar bg-@color" style="width:@pct.ToString("F0")%"></div>
</div>
<small class="text-nowrap text-muted">@dailyLabel</small>
</div>
}
else
{
<small class="text-muted">@dailyLabel</small>
}
</td>
<td style="min-width:130px">
@{
var monthlyLabel = c.MonthlyLimit.HasValue ? $"{c.MonthlySent} / {c.MonthlyLimit}" : c.MonthlySent.ToString();
}
@if (c.MonthlyLimit.HasValue && c.MonthlyLimit > 0)
{
var pct = Math.Min((double)c.MonthlySent / c.MonthlyLimit.Value * 100, 100);
var color = pct >= 100 ? "danger" : pct >= 90 ? "warning" : "success";
<div class="d-flex align-items-center gap-2">
<div class="progress flex-grow-1" style="height:6px; min-width:60px">
<div class="progress-bar bg-@color" style="width:@pct.ToString("F0")%"></div>
</div>
<small class="text-nowrap text-muted">@monthlyLabel</small>
</div>
}
else
{
<small class="text-muted">@monthlyLabel</small>
}
</td>
<td class="text-end">
<a href="/admin/channels/@c.Id"
<a href="/admin/channels/@c.ChannelId"
class="btn btn-sm btn-outline-primary me-1">
<i class="bi bi-pencil"></i> Edit
</a>
<form method="post"
action="/admin/channels/@c.Id/delete"
action="/admin/channels/@c.ChannelId/delete"
class="d-inline">
@Html.AntiForgeryToken()
<button type="submit"