refactor: rename domain types and introduce TransactionBehavior pattern
- Rename Template -> EmailTemplate, Provider -> EmailChannel, ProviderSettings -> EmailChannelSettings, ProviderType -> EmailChannelType, ProviderUsage -> EmailChannelUsage throughout all layers - Add Undefined = 0 to EmailChannelType enum for safe default handling - Remove SaveChangesAsync from EfRepository methods — repositories now only stage changes - Add SaveChangesAsync to IUnitOfWork and EfUnitOfWork - Add TransactionBehavior MediatR pipeline: wraps every handler in a transaction, saves and commits on success, rolls back on exception - Add MediatR package reference to Services project Ref: IT-628 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+4
-4
@@ -2,14 +2,14 @@ using HrynCo.NotificationService.DAL.Abstract.Entities;
|
||||
|
||||
namespace HrynCo.NotificationService.DAL.Abstract.Providers;
|
||||
|
||||
public class Provider : Entity
|
||||
public class EmailChannel : Entity
|
||||
{
|
||||
public required string ServiceName { get; set; }
|
||||
public int Priority { get; set; }
|
||||
public ProviderType ProviderType { get; set; }
|
||||
public required ProviderSettings Settings { get; set; }
|
||||
public EmailChannelType EmailChannelType { get; set; }
|
||||
public required EmailChannelSettings Settings { get; set; }
|
||||
public int? DailyLimit { get; set; }
|
||||
public int? MonthlyLimit { get; set; }
|
||||
public int WarnThresholdPercent { get; set; } = 90;
|
||||
public bool IsActive { get; set; } = true;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
namespace HrynCo.NotificationService.DAL.Abstract.Providers;
|
||||
|
||||
public abstract class ProviderSettings
|
||||
public abstract class EmailChannelSettings
|
||||
{
|
||||
public abstract ProviderType ProviderType { get; }
|
||||
public abstract EmailChannelType EmailChannelType { get; }
|
||||
}
|
||||
|
||||
public class SmtpProviderSettings : ProviderSettings
|
||||
public class SmtpChannelSettings : EmailChannelSettings
|
||||
{
|
||||
public override ProviderType ProviderType => ProviderType.Smtp;
|
||||
public override EmailChannelType EmailChannelType => EmailChannelType.Smtp;
|
||||
|
||||
public required string Host { get; set; }
|
||||
public int Port { get; set; } = 587;
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
namespace HrynCo.NotificationService.DAL.Abstract.Providers;
|
||||
|
||||
public enum ProviderType
|
||||
public enum EmailChannelType
|
||||
{
|
||||
Undefined = 0,
|
||||
Smtp = 1
|
||||
}
|
||||
+2
-2
@@ -3,10 +3,10 @@ using HrynCo.NotificationService.DAL.Abstract.Entities;
|
||||
namespace HrynCo.NotificationService.DAL.Abstract.Providers;
|
||||
|
||||
/// <summary>
|
||||
/// Tracks email send counts per provider per calendar day.
|
||||
/// Tracks email send counts per EmailChannel per calendar day.
|
||||
/// Monthly counts are derived by summing daily records within a month.
|
||||
/// </summary>
|
||||
public class ProviderUsage : Entity
|
||||
public class EmailChannelUsage : Entity
|
||||
{
|
||||
public Guid ProviderId { get; set; }
|
||||
public DateOnly Date { get; set; }
|
||||
Reference in New Issue
Block a user