From df8887f9743e5d1562d28b6a3a1d88db397cdff8 Mon Sep 17 00:00:00 2001 From: Stoyan Zlatev Date: Fri, 9 Jun 2023 13:01:32 +0200 Subject: [PATCH] error fixes, project builds withowt errors --- .../LoggerService.cs | 14 ++--- .../SoftwareService.cs | 58 +++++++++---------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/LaaProductionWeb/LaaProductionWeb.Services/LoggerService.cs b/LaaProductionWeb/LaaProductionWeb.Services/LoggerService.cs index 57ed2f39..ead443ea 100644 --- a/LaaProductionWeb/LaaProductionWeb.Services/LoggerService.cs +++ b/LaaProductionWeb/LaaProductionWeb.Services/LoggerService.cs @@ -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(); } } diff --git a/LaaProductionWeb/LaaProductionWeb.Services/SoftwareService.cs b/LaaProductionWeb/LaaProductionWeb.Services/SoftwareService.cs index 7eb7ff54..a94d46a6 100644 --- a/LaaProductionWeb/LaaProductionWeb.Services/SoftwareService.cs +++ b/LaaProductionWeb/LaaProductionWeb.Services/SoftwareService.cs @@ -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 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 GetAllSoftwareFunctions() - => this.sqlClient + => this.fluentSQL .CreateCommand($@" SELECT [Id] , [AppId] @@ -100,7 +100,7 @@ }); public IEnumerable GetSoftwareFunctions(short appId) - => this.sqlClient + => this.fluentSQL .CreateCommand($@" SELECT [Id] , [AppId] @@ -116,7 +116,7 @@ }); public IEnumerable 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 GetSoftwareVersions(short appId) - => this.sqlClient + => this.fluentSQL .CreateCommand($@" SELECT [SoftwareAccess_ID] , [AppID] @@ -181,7 +181,7 @@ }); public IEnumerable GetSoftwares() - => this.sqlClient + => this.fluentSQL .CreateCommand(@" SELECT [VSA].[AppId] AS [AppId] , [VSA].[SoftwareAccess_Program] AS [Program] @@ -201,7 +201,7 @@ }); public IEnumerable GetUsers(string username = null) - => this.sqlClient + => this.fluentSQL .CreateCommand($@" SELECT [U].[MitarbeiterNr] , [U].[Vorname] @@ -235,7 +235,7 @@ }); public IEnumerable 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()) { - 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()) { - this.sqlClient + this.fluentSQL .CreateCommand($@" INSERT INTO [UsersFunctions] ([UserId] ,[SoftwareFunctionId])