Jonathan Jenne 56688d2690 20-11-23
2023-11-20 16:42:11 +01:00

84 lines
2.7 KiB
VB.net

Public Class Envelope
Public Property Id As Integer = 0
Public Property UserId As Integer
Public Property Title As String = ""
Public Property ContractType As Constants.ContractType
Public Property Status As Constants.EnvelopeStatus
Public Property Uuid As String = Guid.NewGuid.ToString()
Public Property Subject As String = My.Resources.Envelope.You_received_a_document_to_sign_
Public Property Message As String = My.Resources.Envelope.Please_read_and_sign_this_document
Public Property AddedWhen As Date
Public Property User As New User()
Public Property Documents As New List(Of EnvelopeDocument)
Public Property Receivers As New List(Of EnvelopeReceiver)
Public ReadOnly Property StatusTranslated As String
Get
Dim oStatus = Status.ToString()
Return My.Resources.Model.ResourceManager.GetString(oStatus)
End Get
End Property
Public ReadOnly Property ContractTypeTranslated As String
Get
Dim oContractType = ContractType.ToString()
Return My.Resources.Model.ResourceManager.GetString(oContractType)
End Get
End Property
Public Function Validate() As List(Of String)
Dim oErrors As New List(Of String)
If String.IsNullOrWhiteSpace(Subject) Then
oErrors.Add(My.Resources.Envelope.Missing_Subject)
End If
If String.IsNullOrWhiteSpace(Message) Then
oErrors.Add(My.Resources.Envelope.Missing_Message)
End If
If Documents.Count = 0 Then
oErrors.Add(My.Resources.Envelope.Missing_Documents)
End If
If Receivers.Count = 0 Then
oErrors.Add(My.Resources.Envelope.Missing_Receivers)
End If
For Each Receiver In Receivers
If IsValidEmailAddress(Receiver.Email) = False Then
oErrors.Add(String.Format(My.Resources.Envelope.Invalid_Email_Address, Receiver.Name))
End If
Next
Return oErrors
End Function
Public Function ValidateReceiverDocumentData() As List(Of String)
Dim oErrors As New List(Of String)
If Documents.Count = 0 Then
oErrors.Add(My.Resources.Envelope.Missing_Documents)
End If
If Receivers.Count = 0 Then
oErrors.Add(My.Resources.Envelope.Missing_Receivers)
End If
Return oErrors
End Function
Private Function IsValidEmailAddress(pEmailAddress As String) As Boolean
Try
Dim oAddress = New System.Net.Mail.MailAddress(pEmailAddress)
Return oAddress.Address = pEmailAddress
Catch ex As Exception
Return False
End Try
End Function
End Class