refactor(EnvelopeGenerator.Common): umbenennen in EnvelopeGenerator.CommonService
This commit is contained in:
85
EnvelopeGenerator.CommonServices/Models/UserModel.vb
Normal file
85
EnvelopeGenerator.CommonServices/Models/UserModel.vb
Normal file
@@ -0,0 +1,85 @@
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports EnvelopeGenerator.Domain.Entities
|
||||
|
||||
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 CheckUserLogin(pUser As User) As User
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [dbo].[FNDD_LOGIN_USER_MODULE] ('{pUser.Username}', 'SIG_ENV_CR', 1)"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSql)
|
||||
|
||||
If oTable?.Rows.Count = 0 Then
|
||||
Return pUser
|
||||
End If
|
||||
|
||||
Dim oRow = oTable.Rows.Item(0)
|
||||
Dim oHasAccess = oRow.ItemEx("MODULE_ACCESS", False)
|
||||
Dim oIsAdmin = oRow.ItemEx("IS_ADMIN", False)
|
||||
Dim oGhostmode = oRow.ItemEx("GHOST_MODE_OVERRIDE", False)
|
||||
pUser.HasAccess = oHasAccess
|
||||
pUser.IsAdmin = oIsAdmin
|
||||
pUser.GhostModeActive = oGhostmode
|
||||
Return pUser
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return pUser
|
||||
End Try
|
||||
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
|
||||
|
||||
Public Function SelectUserId(oUserName As String) As Integer
|
||||
Try
|
||||
Dim oUserId As Integer = Database.GetScalarValue($"SELECT GUID FROM TBDD_USER WHERE USERNAME = '{oUserName}'")
|
||||
Return oUserId
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return 0
|
||||
End Try
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user