SQL-Abfragen in Models verschoben
User Model neu
This commit is contained in:
39
EnvelopeGenerator.Common/Models/UserModel.vb
Normal file
39
EnvelopeGenerator.Common/Models/UserModel.vb
Normal file
@@ -0,0 +1,39 @@
|
||||
Imports System.Data.SqlClient
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports EnvelopeGenerator.Common.My.Resources
|
||||
|
||||
Public Class UserModel
|
||||
Inherits BaseModel
|
||||
|
||||
Public Sub New(pState As State)
|
||||
MyBase.New(pState)
|
||||
End Sub
|
||||
|
||||
Private Function ToUser(pRow As DataRow) As User
|
||||
Dim oUser = New User() With {
|
||||
.Id = pRow.ItemEx("GUID", 0),
|
||||
.Prename = pRow.ItemEx("PRENAME", ""),
|
||||
.Name = pRow.ItemEx("NAME", ""),
|
||||
.Username = pRow.ItemEx("USERNAME", ""),
|
||||
.Email = pRow.ItemEx("EMAIL", ""),
|
||||
.Language = pRow.ItemEx("LANGUAGE", "")
|
||||
}
|
||||
|
||||
Return oUser
|
||||
End Function
|
||||
|
||||
Public Function SelectUser() As User
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [dbo].[TBDD_USER] WHERE USER_ID = {State.UserId}"
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
|
||||
Return oTable?.Rows.Cast(Of DataRow).
|
||||
Select(AddressOf ToUser)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user