Retructured solution
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
using LiteCharms.Features.Shop;
|
||||
using LiteCharms.Models;
|
||||
|
||||
namespace LiteCharms.Features.Notifications.Commands;
|
||||
|
||||
public class CreateNotification : IRequest<Result<Guid>>
|
||||
{
|
||||
public NotificationDirection Direction { get; set; }
|
||||
|
||||
public string? Sender { get; set; }
|
||||
|
||||
public string? SenderAddress { get; set; }
|
||||
|
||||
public string? Subject { get; set; }
|
||||
|
||||
public string? Message { get; set; }
|
||||
|
||||
public NotificationPlatforms Platform { get; set; }
|
||||
|
||||
public Priorities Priority { get; set; }
|
||||
|
||||
public string? Recipient { get; set; }
|
||||
|
||||
public string? RecipientAddress { get; set; }
|
||||
|
||||
public string? CorrelationId { get; set; }
|
||||
|
||||
public CorrelationIdTypes CorrelationIdType { get; set; }
|
||||
|
||||
public bool IsInternal { get; set; }
|
||||
|
||||
public bool IsHtml { get; set; }
|
||||
|
||||
private CreateNotification(NotificationDirection direction, string sender, string senderAddress, string subject, string message, NotificationPlatforms platform, Priorities priority, string recipient, string recipientAddress, string correlationId, CorrelationIdTypes correlationIdType, bool isInternal, bool isHtml = false)
|
||||
{
|
||||
Direction = direction;
|
||||
Sender = sender;
|
||||
SenderAddress = senderAddress;
|
||||
Subject = subject;
|
||||
Message = message;
|
||||
Platform = platform;
|
||||
Priority = priority;
|
||||
Recipient = recipient;
|
||||
RecipientAddress = recipientAddress;
|
||||
CorrelationId = correlationId;
|
||||
CorrelationIdType = correlationIdType;
|
||||
IsInternal = isInternal;
|
||||
IsHtml = isHtml;
|
||||
}
|
||||
|
||||
public static CreateNotification Create(NotificationDirection direction, string sender, string senderAddress, string subject, string message, NotificationPlatforms platform, Priorities priority, string recipient, string recipientAddress, string correlationId, CorrelationIdTypes correlationIdType, bool isInternal, bool isHtml = false)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(sender))
|
||||
throw new ArgumentException("Sender name is required.", nameof(sender));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(subject))
|
||||
throw new ArgumentException("Subject is required.", nameof(subject));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(message))
|
||||
throw new ArgumentException("Message is required.", nameof(message));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(recipient))
|
||||
throw new ArgumentException("Recipient name is required.", nameof(recipient));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(recipientAddress))
|
||||
throw new ArgumentException("Recipient address is required.", nameof(recipientAddress));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(correlationId))
|
||||
throw new ArgumentException("CorrelationId is required.", nameof(correlationId));
|
||||
|
||||
return new(direction, sender, senderAddress, subject, message, platform, priority, recipient, recipientAddress, correlationId, correlationIdType, isInternal, isHtml);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user