2023-09-20 13:46:34 +02:00

51 lines
1.4 KiB
VB.net

Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Logging
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 GUID = {State.UserId}"
Dim oTable = Database.GetDatatable(oSql)
Return oTable?.Rows.Cast(Of DataRow).
Select(AddressOf ToUser).First
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
End Function
Public Function SelectUser(pUserID As Integer) As User
Try
Dim oSql = $"SELECT * FROM [dbo].[TBDD_USER] WHERE GUID = {pUserID}"
Dim oTable = Database.GetDatatable(oSql)
Return oTable?.Rows.Cast(Of DataRow).
Select(AddressOf ToUser).First
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
End Function
End Class