error fixes, project builds withowt errors

This commit is contained in:
Stoyan Zlatev 2023-06-09 13:01:32 +02:00
parent 085c695c29
commit df8887f974
2 changed files with 36 additions and 36 deletions

View File

@ -7,10 +7,10 @@
public class LoggerService : ILoggerService
{
private readonly ISqlClient sqlClient;
private readonly IFluentSQL fluentSQL;
public LoggerService(ISqlClient sqlClient)
=> this.sqlClient = sqlClient;
public LoggerService(IFluentSQL fluentSQL)
=> this.fluentSQL = fluentSQL;
public class Actions
{
@ -36,7 +36,7 @@
var model = new LogModel();
logModel?.Invoke(model);
this.sqlClient
this.fluentSQL
.CreateCommand($@"
INSERT INTO [SoftwareFunctionsLog] (
[User]
@ -45,9 +45,9 @@
VALUES (@{nameof(model.User)}
, @{nameof(model.Action)}
, @{nameof(model.Data)})")
.AddParameter(nameof(model.User), model.User)
.AddParameter(nameof(model.Action), model.Action)
.AddParameter(nameof(model.Data), model.Data)
.SetParameter(nameof(model.User), model.User)
.SetParameter(nameof(model.Action), model.Action)
.SetParameter(nameof(model.Data), model.Data)
.ExecuteNonQuery();
}
}

View File

@ -12,13 +12,13 @@
public class SoftwareService : ISoftwareService
{
private readonly IFluentSQL sqlClient;
private readonly IFluentSQL fluentSQL;
public SoftwareService(IFluentSQL sqlClient)
=> this.sqlClient = sqlClient;
public SoftwareService(IFluentSQL fluentSQL)
=> this.fluentSQL = fluentSQL;
public void AddFunction(short appId, string name)
=> this.sqlClient
=> this.fluentSQL
.CreateCommand($@"
INSERT INTO [SoftwareFunctions] (
[AppId]
@ -30,24 +30,24 @@
.ExecuteNonQuery();
public int ApplicationId(string name)
=> this.sqlClient
=> this.fluentSQL
.CreateCommand($@"
SELECT TOP 1 [AppId]
FROM [VersionSoftwareAccess]
WHERE [SoftwareAccess_Program] = @{nameof(name)}")
.AddParameter(nameof(name), name)
.SetParameter(nameof(name), name)
.FirstOrDefault(x => x.GetSmallint());
public void DeleteFunction(int funcId)
{
this.sqlClient
this.fluentSQL
.CreateCommand($@"
DELETE FROM [SoftwareFunctions]
WHERE [Id] = @{nameof(funcId)}")
.SetParameter(nameof(funcId), funcId)
.ExecuteNonQuery();
this.sqlClient
this.fluentSQL
.CreateCommand($@"
DELETE FROM [UsersFunctions]
WHERE [SoftwareFunctionId] = @{nameof(funcId)}")
@ -57,14 +57,14 @@
public short FindAndUpdateSoftware(string windowsUser, string name, IEnumerable<string> functions)
{
var appId = this.sqlClient
var appId = this.fluentSQL
.CreateCommand($@"
SELECT TOP 1 [AppId]
, MAX([SoftwareAccess_VaildTo]) OVER (PARTITION BY [AppId])
FROM [VersionSoftwareAccess]
WHERE [SoftwareAccess_Program] = @{nameof(name)}
AND [SoftwareAccess_VaildTo] > GETDATE()")
.AddParameter(nameof(name), name)
.SetParameter(nameof(name), name)
.FirstOrDefault(x => x.GetSmallint());
if (appId > 0)
@ -86,7 +86,7 @@
}
public IEnumerable<SoftwareFunction> GetAllSoftwareFunctions()
=> this.sqlClient
=> this.fluentSQL
.CreateCommand($@"
SELECT [Id]
, [AppId]
@ -100,7 +100,7 @@
});
public IEnumerable<SoftwareFunction> GetSoftwareFunctions(short appId)
=> this.sqlClient
=> this.fluentSQL
.CreateCommand($@"
SELECT [Id]
, [AppId]
@ -116,7 +116,7 @@
});
public IEnumerable<string> GetSoftwareFunctions(short appId, short userId)
=> this.sqlClient
=> this.fluentSQL
.CreateCommand($@"
SELECT [SF].[Function] AS [Function]
FROM [UsersFunctions] AS [UF]
@ -124,12 +124,12 @@
ON [SF].[Id] = [UF].[SoftwareFunctionId]
WHERE [UF].[UserId] = @{nameof(userId)}
AND [SF].[AppId] = @{nameof(appId)}")
.AddParameter(nameof(appId), appId)
.AddParameter(nameof(userId), userId)
.SetParameter(nameof(appId), appId)
.SetParameter(nameof(userId), userId)
.ExecuteReader(x => x.GetString());
public SoftwareOverview GetSoftwareOverview(short appId)
=> this.sqlClient
=> this.fluentSQL
.CreateCommand($@"
SELECT [vsa].[AppID]
, [vsa].[SoftwareAccess_Program]
@ -151,7 +151,7 @@
});
public IEnumerable<Software> GetSoftwareVersions(short appId)
=> this.sqlClient
=> this.fluentSQL
.CreateCommand($@"
SELECT [SoftwareAccess_ID]
, [AppID]
@ -181,7 +181,7 @@
});
public IEnumerable<SoftwareOverview> GetSoftwares()
=> this.sqlClient
=> this.fluentSQL
.CreateCommand(@"
SELECT [VSA].[AppId] AS [AppId]
, [VSA].[SoftwareAccess_Program] AS [Program]
@ -201,7 +201,7 @@
});
public IEnumerable<SoftwareUser> GetUsers(string username = null)
=> this.sqlClient
=> this.fluentSQL
.CreateCommand($@"
SELECT [U].[MitarbeiterNr]
, [U].[Vorname]
@ -235,7 +235,7 @@
});
public IEnumerable<SoftwareUser> GetUsersWithFunctions(int userId = -1, string username = null)
=> this.sqlClient
=> this.fluentSQL
.CreateCommand($@"
SELECT [U].[MitarbeiterNr]
, [U].[Vorname]
@ -278,7 +278,7 @@
});
public void UpdateFunction(int funcId, string name)
=> this.sqlClient
=> this.fluentSQL
.CreateCommand($@"
UPDATE [SoftwareFunctions]
SET [Function] = @{nameof(name)}
@ -289,7 +289,7 @@
public void UpdatePasswordHashes()
{
var pwdUsers = this.sqlClient
var pwdUsers = this.fluentSQL
.CreateCommand($@"
SELECT [MitarbeiterNr]
, [Kennwort]
@ -306,7 +306,7 @@
var userId = kvp.Key;
var password = sha256.ComputeHash(kvp.Value);
this.sqlClient
this.fluentSQL
.CreateCommand($@"
UPDATE [Mitarbeiter]
SET [PasswordHash] = @{nameof(password)}
@ -318,7 +318,7 @@
}
public int ResetPassword(short userId)
=> this.sqlClient
=> this.fluentSQL
.CreateCommand($@"
UPDATE [Mitarbeiter]
SET [PasswordHash] = NULL
@ -330,7 +330,7 @@
{
password = SHA256.Create().ComputeHash(password);
return this.sqlClient
return this.fluentSQL
.CreateCommand($@"
UPDATE [Mitarbeiter]
SET [PasswordHash] = @{nameof(password)}
@ -347,14 +347,14 @@
var userId = model.UserId;
this.sqlClient
this.fluentSQL
.CreateCommand($@"DELETE FROM [UsersFunctions] WHERE [UserId] = @{nameof(userId)}")
.SetParameter(nameof(userId), userId)
.ExecuteNonQuery();
foreach (var funcId in model.Functions ?? Array.Empty<int>())
{
this.sqlClient
this.fluentSQL
.CreateCommand($@"
INSERT
INTO [UsersFunctions] ([UserId] ,[SoftwareFunctionId])
@ -372,14 +372,14 @@
var funcId = model.FunctionId;
this.sqlClient
this.fluentSQL
.CreateCommand($@"DELETE FROM [UsersFunctions] WHERE [SoftwareFunctionId] = @{nameof(funcId)}")
.SetParameter(nameof(funcId), funcId)
.ExecuteNonQuery();
foreach (var userId in model.Users ?? Array.Empty<short>())
{
this.sqlClient
this.fluentSQL
.CreateCommand($@"
INSERT
INTO [UsersFunctions] ([UserId] ,[SoftwareFunctionId])