09-08-2023
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Data.Common
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Database
|
||||
@@ -42,7 +43,7 @@ Public Class EnvelopeEditorController
|
||||
|
||||
Envelope = pEnvelope
|
||||
Envelope.Documents = DocumentModel.List(pEnvelope.Id)
|
||||
Envelope.Receivers = ReceiverModel.List(pEnvelope.Id)
|
||||
Envelope.Receivers = ReceiverModel.ListEnvelopeReceivers(pEnvelope.Id)
|
||||
End Sub
|
||||
|
||||
Private Sub InitializeModels(pState As State)
|
||||
@@ -66,8 +67,8 @@ Public Class EnvelopeEditorController
|
||||
.EnvelopeId = oEnvelope.Id,
|
||||
.Status = HistoryStatus.Created,
|
||||
.ActionTitle = "Envelope erzeugt",
|
||||
.ActionDescription = "Envelope wurde erzeugt",
|
||||
}
|
||||
.ActionDescription = "Envelope wurde erzeugt"
|
||||
}
|
||||
'TODO .UserEmailAddress = oEnvelope.User.Email ' TODO - fehlt noch
|
||||
|
||||
Return oEnvelope
|
||||
@@ -81,7 +82,7 @@ Public Class EnvelopeEditorController
|
||||
Dim oTransaction = oConnection.BeginTransaction(IsolationLevel.ReadUncommitted)
|
||||
|
||||
Try
|
||||
pEnvelope.Status = Common.Constants.EnvelopeStatus.Created
|
||||
pEnvelope.Status = EnvelopeStatus.Saved
|
||||
|
||||
If SaveEnvelopeDocumentsToFilesystem(pEnvelope) = False Then
|
||||
Throw New ApplicationException
|
||||
@@ -205,16 +206,50 @@ Public Class EnvelopeEditorController
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function CreateEnvelopeReceivers(pReceivers As List(Of EnvelopeReceiver)) As Boolean
|
||||
Dim oExistingReceivers As List(Of EnvelopeReceiver) = ReceiverModel.ListReceivers(pReceivers)
|
||||
Dim oExistingAddresses = oExistingReceivers.Select(Function(r) r.Email)
|
||||
|
||||
Dim oNewReceivers = pReceivers.
|
||||
Where(Function(r) Not oExistingAddresses.Contains(r.Email)).ToList()
|
||||
|
||||
Dim oOldReceivers = pReceivers.
|
||||
Where(Function(r) oExistingAddresses.Contains(r.Email)).ToList()
|
||||
|
||||
For Each oReceiver In oOldReceivers
|
||||
oReceiver.Id = oExistingReceivers.
|
||||
Where(Function(r) r.Email = oReceiver.Email).
|
||||
Select(Function(r) r.Id).
|
||||
FirstOrDefault()
|
||||
Next
|
||||
|
||||
Dim oConnection = Database.GetConnection()
|
||||
Dim oTransaction = oConnection.BeginTransaction()
|
||||
|
||||
Try
|
||||
|
||||
If InsertReceivers(oNewReceivers, oTransaction) = False Then
|
||||
Throw New ApplicationException("Could not insert receivers!")
|
||||
End If
|
||||
|
||||
oTransaction.Commit()
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
oTransaction.Rollback()
|
||||
|
||||
Return False
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function SaveEnvelopeReceivers(pEnvelope As Envelope, pTransaction As SqlTransaction) As Boolean
|
||||
Try
|
||||
If pEnvelope.Id = Nothing Then
|
||||
Throw New ArgumentNullException("EnvelopeId")
|
||||
End If
|
||||
|
||||
If InsertReceivers(pEnvelope.Receivers, pTransaction) = False Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
If AssignReceivers(pEnvelope, pTransaction) = False Then
|
||||
Return False
|
||||
End If
|
||||
@@ -262,10 +297,6 @@ Public Class EnvelopeEditorController
|
||||
End Function
|
||||
|
||||
Private Function InsertReceiver(pReceiver As EnvelopeReceiver, pTransaction As SqlTransaction) As Boolean
|
||||
If ReceiverModel.TestReceiverExists(pReceiver) Then
|
||||
Return True
|
||||
End If
|
||||
|
||||
If pReceiver.HasId = False Then
|
||||
Return ReceiverModel.Insert(pReceiver, pTransaction)
|
||||
Else
|
||||
|
||||
Reference in New Issue
Block a user