SQL-Abfragen in Models verschoben
User Model neu
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Transactions
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports EnvelopeGenerator.Common.My.Resources
|
||||
|
||||
Public Class DocumentModel
|
||||
Inherits BaseModel
|
||||
|
||||
@@ -30,4 +34,44 @@ Public Class DocumentModel
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Insert(pEnvelope As Envelope, pDocument As EnvelopeDocument, pTransaction As SqlTransaction) As Boolean
|
||||
Try
|
||||
Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE_DOCUMENT]
|
||||
([FILENAME]
|
||||
,[FILEPATH]
|
||||
,[ENVELOPE_ID])
|
||||
VALUES
|
||||
(@FILENAME
|
||||
,@FILEPATH
|
||||
,@ENVELOPE_ID)"
|
||||
|
||||
Dim oCommand As New SqlCommand(oSql)
|
||||
oCommand.Parameters.Add("FILENAME", SqlDbType.NVarChar).Value = pDocument.Filename
|
||||
oCommand.Parameters.Add("FILEPATH", SqlDbType.NVarChar).Value = pDocument.Filepath
|
||||
oCommand.Parameters.Add("ENVELOPE_ID", SqlDbType.Int).Value = pEnvelope.Id
|
||||
|
||||
If Database.ExecuteNonQuery(oCommand, pTransaction) Then
|
||||
pDocument.EnvelopeId = pEnvelope.Id
|
||||
pDocument.Id = GetDocumentId(pDocument.Filename, pEnvelope, pTransaction)
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetDocumentId(pFilename As String, pEnvelope As Envelope, pTransaction As SqlTransaction) As Integer
|
||||
Try
|
||||
Return Database.GetScalarValue($"SELECT MAX(GUID) FROM TBSIG_ENVELOPE_DOCUMENT WHERE FILENAME = '{pFilename}' AND ENVELOPE_ID = {pEnvelope.Id}", pTransaction)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user