Personalization done
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
using LaaProductionSQL.Interfaces;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
internal class EmployeesRepository : IEmployeesRepository
|
||||
{
|
||||
@@ -18,17 +19,43 @@
|
||||
=> this.sqlConnection
|
||||
.CreateCommand($@"
|
||||
SELECT [M].[MitarbeiterNr] AS [EmployeeId]
|
||||
, [M].[Vorname] + ' ' + [M].[Name] AS [FullName]
|
||||
, [M].[Benutzername] AS [Username]
|
||||
, [M].[Vorname] + ' ' + [M].[Name] AS [FullName]
|
||||
, [M].[Benutzername] AS [Username]
|
||||
, [M].[PasswordHash] AS [Password]
|
||||
FROM [Mitarbeiter] AS [M]
|
||||
, [MR].[Recht] AS [Role]
|
||||
, [SF].[Function] AS [Function]
|
||||
FROM [Mitarbeiter] AS [M]
|
||||
LEFT JOIN [MitarbeiterRechte] AS [MR]
|
||||
ON [MR].[MitarbeiterNr] = [M].[MitarbeiterNr]
|
||||
LEFT JOIN [UsersFunctions] AS [UF]
|
||||
ON [UF].[UserId] = [M].[MitarbeiterNr]
|
||||
LEFT JOIN [SoftwareFunctions] AS [SF]
|
||||
ON [SF].[Id] = [UF].[SoftwareFunctionId]
|
||||
ORDER BY [FullName], [Username]")
|
||||
.ExecuteReader(x => new Employee
|
||||
.ExecuteReader(x => new
|
||||
{
|
||||
EmployeeId = x.GetSmallint(),
|
||||
FullName = x.GetString(),
|
||||
Username = x.GetString(),
|
||||
HasPassword = !string.IsNullOrWhiteSpace(x.GetString())
|
||||
HasPassword = !string.IsNullOrWhiteSpace(x.GetString()),
|
||||
Role = x.GetString(),
|
||||
Function = x.GetString()
|
||||
})
|
||||
.GroupBy(x => new Employee
|
||||
{
|
||||
EmployeeId = x.EmployeeId,
|
||||
FullName = x.FullName,
|
||||
Username = x.Username,
|
||||
HasPassword = x.HasPassword,
|
||||
}, new EmployeeComparer())
|
||||
.Select(x =>
|
||||
{
|
||||
x.Key.Roles = x.Select(r => r.Role).Distinct();
|
||||
x.Key.RolesCount = x.Key.Roles.Count();
|
||||
x.Key.Functions = x.Select(f => f.Function).Distinct();
|
||||
x.Key.FunctionsCount = x.Key.Functions.Count();
|
||||
|
||||
return x.Key;
|
||||
});
|
||||
|
||||
public void CreateToken(short appId, short userId)
|
||||
|
||||
Reference in New Issue
Block a user