Refactor email content logic into EmailData class
Move dynamic message and signature type logic from TemplateService to EmailData via DynamicStringsForEmails. Constructors now set and HTML-encode these properties. Improves maintainability by centralizing email content generation.
This commit is contained in:
@@ -23,6 +23,18 @@ Public Class EmailData
|
||||
Public Property ADDED_WHO_PROCESS As String = "DDEnvelopGenerator"
|
||||
|
||||
Public ReadOnly Property EnvelopeTypeId As Integer = 0
|
||||
Public Property SignatureType As String = ""
|
||||
|
||||
Public Sub DynamicStringsForEmails(pEnvelope As Entities.Envelope)
|
||||
|
||||
If pEnvelope.EnvelopeTypeId = 1 Then
|
||||
SignatureType = "Signieren"
|
||||
Message = "Bitte lesen und unterzeichnen Sie dieses Dokument."
|
||||
ElseIf pEnvelope.EnvelopeTypeId = 2 Then
|
||||
SignatureType = "Lesen und bestätigen"
|
||||
Message = "Bitte lesen und bestätigen Sie, dieses Dokument gelesen zu haben."
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Constructor for sending email to receiver
|
||||
@@ -31,11 +43,14 @@ Public Class EmailData
|
||||
''' <param name="pReceiver"></param>
|
||||
''' <param name="pStatus"></param>
|
||||
Public Sub New(pEnvelope As Entities.Envelope, pReceiver As Receiver, pStatus As Constants.EnvelopeStatus)
|
||||
|
||||
DynamicStringsForEmails(pEnvelope)
|
||||
|
||||
EmailAdress = pReceiver.EmailAddress
|
||||
EmailSubject = String.Empty
|
||||
EmailType = pStatus
|
||||
|
||||
Message = TextToHtml(pEnvelope.Message)
|
||||
Message = TextToHtml(Message)
|
||||
ReferenceID = pEnvelope.Id
|
||||
ReferenceString = pEnvelope.Uuid
|
||||
ReceiverName = pReceiver.Name
|
||||
@@ -44,6 +59,7 @@ Public Class EmailData
|
||||
SenderName = pEnvelope.User.GetFullName()
|
||||
EnvelopeTitle = pEnvelope.Title
|
||||
EnvelopeTypeId = pEnvelope.EnvelopeTypeId
|
||||
SignatureType = TextToHtml(SignatureType)
|
||||
End Sub
|
||||
Public Function TextToHtml(input As String) As String
|
||||
If String.IsNullOrEmpty(input) Then Return ""
|
||||
@@ -68,11 +84,14 @@ Public Class EmailData
|
||||
''' <param name="pEnvelope"></param>
|
||||
''' <param name="pStatus"></param>
|
||||
Public Sub New(pEnvelope As Entities.Envelope, pStatus As Constants.EnvelopeStatus)
|
||||
|
||||
DynamicStringsForEmails(pEnvelope)
|
||||
|
||||
EmailAdress = pEnvelope.User.Email
|
||||
EmailSubject = String.Empty
|
||||
EmailType = pStatus
|
||||
|
||||
Message = pEnvelope.Message
|
||||
Message = TextToHtml(Message)
|
||||
ReferenceID = pEnvelope.Id
|
||||
ReferenceString = pEnvelope.Uuid
|
||||
ReceiverName = pEnvelope.User.GetFullName()
|
||||
@@ -81,6 +100,7 @@ Public Class EmailData
|
||||
SenderName = pEnvelope.User.GetFullName()
|
||||
EnvelopeTitle = pEnvelope.Title
|
||||
EnvelopeTypeId = pEnvelope.EnvelopeTypeId
|
||||
SignatureType = TextToHtml(SignatureType)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user