Updated email functionality
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
<!-- Nuget Package Details -->
|
<!-- Nuget Package Details -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PackageId>LiteCharms.Features</PackageId>
|
<PackageId>LiteCharms.Features</PackageId>
|
||||||
<Version>1.0.15</Version>
|
<Version>1.0.16</Version>
|
||||||
<Authors>Khwezi Mngoma</Authors>
|
<Authors>Khwezi Mngoma</Authors>
|
||||||
<Company>Lite Charms (PTY) Ltd</Company>
|
<Company>Lite Charms (PTY) Ltd</Company>
|
||||||
<Description>Feature components for Lite Charms applications.</Description>
|
<Description>Feature components for Lite Charms applications.</Description>
|
||||||
|
|||||||
@@ -36,43 +36,43 @@ public class SendEmailCommand : IRequest<Result>
|
|||||||
public static SendEmailCommand Create(string from, string senderName, string to, string recipientName, string subject, string message, bool isHtml = false, Stream? attachment = null, string? attachmentFileName = null)
|
public static SendEmailCommand Create(string from, string senderName, string to, string recipientName, string subject, string message, bool isHtml = false, Stream? attachment = null, string? attachmentFileName = null)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(from))
|
if (string.IsNullOrWhiteSpace(from))
|
||||||
throw new ArgumentException("From address cannot be null or empty.", nameof(from));
|
throw new ArgumentException("From address is required.");
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(senderName))
|
if (string.IsNullOrWhiteSpace(senderName))
|
||||||
throw new ArgumentException("Sender name cannot be null or empty.", nameof(senderName));
|
throw new ArgumentException("Sender name is required.");
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(senderName) && senderName?.Length > 255)
|
if (!string.IsNullOrWhiteSpace(senderName) && senderName?.Length > 255)
|
||||||
throw new ArgumentException("Sender name cannot exceed 255 characters.", nameof(senderName));
|
throw new ArgumentException("Sender name cannot exceed 255 characters.");
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(to))
|
if (string.IsNullOrWhiteSpace(to))
|
||||||
throw new ArgumentException("To address cannot be null or empty.", nameof(to));
|
throw new ArgumentException("To address is required.");
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(recipientName))
|
if (string.IsNullOrWhiteSpace(recipientName))
|
||||||
throw new ArgumentException("Recipient name cannot be null or empty.", nameof(recipientName));
|
throw new ArgumentException("Recipient name is required.");
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(recipientName) && recipientName?.Length > 255)
|
if (!string.IsNullOrWhiteSpace(recipientName) && recipientName?.Length > 255)
|
||||||
throw new ArgumentException("Recipient name cannot exceed 255 characters.", nameof(recipientName));
|
throw new ArgumentException("Recipient name cannot exceed 255 characters.");
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(subject))
|
if (string.IsNullOrWhiteSpace(subject))
|
||||||
throw new ArgumentException("Subject cannot be null or empty.", nameof(subject));
|
throw new ArgumentException("Subject is required.");
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(subject) && subject?.Length > 2048)
|
if (!string.IsNullOrWhiteSpace(subject) && subject?.Length > 2048)
|
||||||
throw new ArgumentException("Subject cannot exceed 2048 characters.", nameof(subject));
|
throw new ArgumentException("Subject cannot exceed 2048 characters.");
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(message))
|
if (string.IsNullOrWhiteSpace(message))
|
||||||
throw new ArgumentException("Message cannot be null or empty.", nameof(message));
|
throw new ArgumentException("Message is required.");
|
||||||
|
|
||||||
if (message.Length > 10485760)
|
if (message.Length > 10485760)
|
||||||
throw new ArgumentException("Message cannot exceed 10 MB.", nameof(message));
|
throw new ArgumentException("Message cannot exceed 10 MB.");
|
||||||
|
|
||||||
if (attachment != null && string.IsNullOrWhiteSpace(attachmentFileName))
|
if (attachment != null && string.IsNullOrWhiteSpace(attachmentFileName))
|
||||||
throw new ArgumentException("Attachment file name must be provided when an attachment is included.", nameof(attachmentFileName));
|
throw new ArgumentException("Attachment file name must be provided when an attachment is included.");
|
||||||
|
|
||||||
if (attachment is not null && attachment.Length > 10485760)
|
if (attachment is not null && attachment.Length > 10485760)
|
||||||
throw new ArgumentException("Attachment cannot exceed 10 MB.", nameof(attachment));
|
throw new ArgumentException("Attachment cannot exceed 10 MB.");
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(attachmentFileName) && attachmentFileName.Length > 255)
|
if (!string.IsNullOrWhiteSpace(attachmentFileName) && attachmentFileName.Length > 255)
|
||||||
throw new ArgumentException("Attachment file name cannot exceed 255 characters.", nameof(attachmentFileName));
|
throw new ArgumentException("Attachment file name cannot exceed 255 characters.");
|
||||||
|
|
||||||
return new(from, senderName!, to, recipientName!, subject!, message, isHtml, attachment, attachmentFileName);
|
return new(from, senderName!, to, recipientName!, subject!, message, isHtml, attachment, attachmentFileName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,21 +5,25 @@ public sealed class EmailEnquiry
|
|||||||
[Required]
|
[Required]
|
||||||
[MinLength(2)]
|
[MinLength(2)]
|
||||||
[MaxLength(255)]
|
[MaxLength(255)]
|
||||||
|
[Display(Name = "Full Name")]
|
||||||
public string? FullName { get; set; }
|
public string? FullName { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[EmailAddress]
|
[EmailAddress]
|
||||||
[MinLength(20)]
|
[MinLength(5)]
|
||||||
[MaxLength(255)]
|
[MaxLength(255)]
|
||||||
|
[Display(Name = "Email Address")]
|
||||||
public string? EmailAddress { get; set; }
|
public string? EmailAddress { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[MinLength(2)]
|
[MinLength(2)]
|
||||||
[MaxLength(255)]
|
[MaxLength(255)]
|
||||||
|
[Display(Name = "Subject")]
|
||||||
public string? EmailSubject { get; set; }
|
public string? EmailSubject { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[MinLength(2)]
|
[MinLength(2)]
|
||||||
[MaxLength(2000)]
|
[MaxLength(2000)]
|
||||||
|
[Display(Name = "Message")]
|
||||||
public string? Message { get; set; }
|
public string? Message { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<!-- Nuget Package Details -->
|
<!-- Nuget Package Details -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PackageId>LiteCharms.Models</PackageId>
|
<PackageId>LiteCharms.Models</PackageId>
|
||||||
<Version>1.0.4</Version>
|
<Version>1.0.5</Version>
|
||||||
<Authors>Khwezi Mngoma</Authors>
|
<Authors>Khwezi Mngoma</Authors>
|
||||||
<Company>Lite Charms (PTY) Ltd</Company>
|
<Company>Lite Charms (PTY) Ltd</Company>
|
||||||
<Description>Shared models for Lite Charms applications.</Description>
|
<Description>Shared models for Lite Charms applications.</Description>
|
||||||
|
|||||||
Reference in New Issue
Block a user