feat(ReceiverVM): add From method to be able to generate from EnvelopeReceiver

This commit is contained in:
tekh 2025-08-21 14:43:56 +02:00
parent 9045655262
commit 0f27600c5b
5 changed files with 104 additions and 90 deletions

View File

@ -1,8 +1,5 @@
Imports System.Data.SqlClient Imports System.Data.SqlClient
Imports System.Net.Mail
Imports DevExpress.DataProcessing
Imports DigitalData.Modules.Base Imports DigitalData.Modules.Base
Imports EnvelopeGenerator.CommonServices.EnvelopeGenerator.Domain.Entities
Imports EnvelopeGenerator.Domain.Constants Imports EnvelopeGenerator.Domain.Constants
Imports EnvelopeGenerator.Domain.Entities Imports EnvelopeGenerator.Domain.Entities

View File

@ -2,102 +2,119 @@
Imports EnvelopeGenerator.Domain Imports EnvelopeGenerator.Domain
Imports EnvelopeGenerator.Domain.Entities Imports EnvelopeGenerator.Domain.Entities
Namespace EnvelopeGenerator.Domain.Entities ''' <summary>
''' <summary> ''' Handles the combination of the envelope and receiver for common services and submodules as a view model.
''' Handles the combination of the envelope and receiver for common services and submodules as a view model. ''' </summary>
''' </summary> Public Class ReceiverVM
Public Class ReceiverVM Inherits EnvelopeReceiver
Inherits EnvelopeReceiver
Private ReadOnly Property SReceiver As Receiver Public Shared Function From(source As EnvelopeReceiver) As ReceiverVM
Get Return New ReceiverVM() With {
If Receiver Is Nothing Then .EnvelopeId = source.EnvelopeId,
Receiver = New Receiver() .ReceiverId = source.ReceiverId,
End If .Sequence = source.Sequence,
Return Receiver .Name = source.Name,
End Get .JobTitle = source.JobTitle,
End Property .CompanyName = source.CompanyName,
.PrivateMessage = source.PrivateMessage,
.AccessCode = source.AccessCode,
.AddedWhen = source.AddedWhen,
.ChangedWhen = source.ChangedWhen,
.PhoneNumber = source.PhoneNumber,
.Company = source.Company,
.Status = source.Status,
.Envelope = source.Envelope,
.Receiver = source.Receiver
}
End Function
Public Property Id As Integer Private ReadOnly Property SReceiver As Receiver
Get Get
Return SReceiver.Id If Receiver Is Nothing Then
End Get Receiver = New Receiver()
Set(value As Integer) End If
SReceiver.Id = value Return Receiver
End Set End Get
End Property End Property
Public Property EmailAddress As String Public Property Id As Integer
Get Get
Return SReceiver.EmailAddress Return SReceiver.Id
End Get End Get
Set(value As String) Set(value As Integer)
SReceiver.EmailAddress = value SReceiver.Id = value
End Set End Set
End Property End Property
Public Property Signature As String Public Property EmailAddress As String
Get Get
Return SReceiver.Signature Return SReceiver.EmailAddress
End Get End Get
Set(value As String) Set(value As String)
SReceiver.Signature = value SReceiver.EmailAddress = value
End Set End Set
End Property End Property
Public Property AddedWhen As DateTime Public Property Signature As String
Get Get
Return SReceiver.AddedWhen Return SReceiver.Signature
End Get End Get
Set(value As DateTime) Set(value As String)
SReceiver.AddedWhen = value SReceiver.Signature = value
End Set End Set
End Property End Property
Public Property TotpSecretkey As String Public Property AddedWhen As DateTime
Get Get
Return SReceiver.TotpSecretkey Return SReceiver.AddedWhen
End Get End Get
Set(value As String) Set(value As DateTime)
SReceiver.TotpSecretkey = value SReceiver.AddedWhen = value
End Set End Set
End Property End Property
Public Property TfaRegDeadline As DateTime? Public Property TotpSecretkey As String
Get Get
Return SReceiver.TfaRegDeadline Return SReceiver.TotpSecretkey
End Get End Get
Set(value As DateTime?) Set(value As String)
SReceiver.TfaRegDeadline = value SReceiver.TotpSecretkey = value
End Set End Set
End Property End Property
Public Property TfaRegDeadline As DateTime?
Get
Return SReceiver.TfaRegDeadline
End Get
Set(value As DateTime?)
SReceiver.TfaRegDeadline = value
End Set
End Property
#Region "Model of old service" #Region "Model of old service"
Public Property SignedDate As DateTime = DateTime.MinValue Public Property SignedDate As DateTime = DateTime.MinValue
Public Property ColorType As Constants.ColorType Public Property ColorType As Constants.ColorType
Public ReadOnly Property SignedDateDisplayValue As String Public ReadOnly Property SignedDateDisplayValue As String
Get Get
If SignedDate = DateTime.MinValue Then If SignedDate = DateTime.MinValue Then
Return "-" Return "-"
Else Else
Return SignedDate.ToString("G") Return SignedDate.ToString("G")
End If End If
End Get End Get
End Property End Property
Public ReadOnly Property Color As Color Public ReadOnly Property Color As Color
Get Get
Return ColorType.ToColor() Return ColorType.ToColor()
End Get End Get
End Property End Property
Public Function GetSignature() As String Public Function GetSignature() As String
Return Receiver.GetSignature() Return Receiver.GetSignature()
End Function End Function
#End Region #End Region
End Class End Class
End Namespace

View File

@ -97,7 +97,7 @@ public class EnvelopeController : BaseController
Status = Constants.DocumentStatus.Signed Status = Constants.DocumentStatus.Signed
}); });
var signResult = actionService?.SignEnvelope(response.Envelope, response.Receiver); var signResult = actionService?.SignEnvelope(response.Envelope, ReceiverVM.From(response));
return Ok(new object()); return Ok(new object());
} }

View File

@ -82,7 +82,7 @@ public class EnvelopeOldService
_logger.LogInformation("Envelope receivers found: [{0}]", envelope.Receivers.Count); _logger.LogInformation("Envelope receivers found: [{0}]", envelope.Receivers.Count);
Receiver? receiver = envelope.Receivers.Where(r => r.Id == receiverId).SingleOrDefault(); Receiver? receiver = envelope.Receivers.Where(r => r.ReceiverId == receiverId).SingleOrDefault()?.Receiver;
if (receiver == null) if (receiver == null)
{ {

View File

@ -9,7 +9,7 @@
string encodeEnvelopeKey(Envelope envelope) string encodeEnvelopeKey(Envelope envelope)
{ {
var receiver = envelope.Receivers.First(); var receiver = envelope.Receivers.First();
return Helpers.EncodeEnvelopeReceiverId(envelope.Uuid, receiver.Signature); return Helpers.EncodeEnvelopeReceiverId(envelope.Uuid, receiver.Receiver.Signature);
} }
IEnumerable<IGrouping<EnvelopeStatus, Envelope>> groupEnvelopes(List<Envelope> envelopes) IEnumerable<IGrouping<EnvelopeStatus, Envelope>> groupEnvelopes(List<Envelope> envelopes)