Personalization done
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
using LaaProduction.Personalization.Repositories.Interfaces;
|
||||
using LaaProductionSQL.Interfaces;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal class SoftwareRepository : ISoftwareRepository
|
||||
@@ -13,6 +14,33 @@
|
||||
public SoftwareRepository(ISQLConnection sqlConnection)
|
||||
=> this.sqlConnection = sqlConnection;
|
||||
|
||||
public void AddVersion(short softwareId, string assemblyName, int majorV, int minorV, int buildV, DateTime validUntil, string description)
|
||||
=> this.sqlConnection
|
||||
.CreateCommand($@"
|
||||
INSERT INTO [VersionSoftwareAccess] (
|
||||
[AppID]
|
||||
, [SoftwareAccess_Program]
|
||||
, [SoftwareAccess_MajorVersion]
|
||||
, [SoftwareAccess_MinorVersion]
|
||||
, [SoftwareAccess_BuildVersion]
|
||||
, [SoftwareAccess_VaildTo]
|
||||
, [SoftwareAccess_Desc])
|
||||
VALUES (@{nameof(softwareId)}
|
||||
, @{nameof(assemblyName)}
|
||||
, @{nameof(majorV)}
|
||||
, @{nameof(minorV)}
|
||||
, @{nameof(buildV)}
|
||||
, @{nameof(validUntil)}
|
||||
, @{nameof(description)})")
|
||||
.SetParameter(nameof(softwareId), softwareId)
|
||||
.SetParameter(nameof(assemblyName), assemblyName)
|
||||
.SetParameter(nameof(majorV), majorV)
|
||||
.SetParameter(nameof(minorV), minorV)
|
||||
.SetParameter(nameof(buildV), buildV)
|
||||
.SetParameter(nameof(validUntil), validUntil)
|
||||
.SetParameter(nameof(description), description)
|
||||
.ExecuteNonQuery();
|
||||
|
||||
public short AppId(string software)
|
||||
=> this.sqlConnection
|
||||
.CreateCommand($@"
|
||||
@@ -22,6 +50,66 @@
|
||||
.SetParameter(nameof(software), software)
|
||||
.FirstOrDefault(x => x.GetSmallint());
|
||||
|
||||
public void Delete(int versionId)
|
||||
=> this.sqlConnection
|
||||
.CreateCommand($@"
|
||||
DELETE FROM [VersionSoftwareAccess]
|
||||
WHERE [SoftwareAccess_ID] = @{nameof(versionId)}")
|
||||
.SetParameter(nameof(versionId), versionId)
|
||||
.ExecuteNonQuery();
|
||||
|
||||
public SoftwareDetails Details(int versionId)
|
||||
=> this.sqlConnection
|
||||
.CreateCommand($@"
|
||||
SELECT [AppID]
|
||||
, [SoftwareAccess_Program]
|
||||
, [SoftwareAccess_MajorVersion]
|
||||
, [SoftwareAccess_MinorVersion]
|
||||
, [SoftwareAccess_BuildVersion]
|
||||
, [SoftwareAccess_ID]
|
||||
, [SoftwareAccess_VaildTo]
|
||||
, [SoftwareAccess_Desc]
|
||||
FROM [VersionSoftwareAccess]
|
||||
WHERE [SoftwareAccess_ID] = @{nameof(versionId)}")
|
||||
.SetParameter(nameof(versionId), versionId)
|
||||
.FirstOrDefault(x => new SoftwareDetails
|
||||
{
|
||||
SoftwareId = x.GetSmallint(),
|
||||
AssemblyName = x.GetString(),
|
||||
VersionNr = $"{x.GetInt()}.{x.GetInt()}.{x.GetInt()}",
|
||||
VersionId = x.GetInt(),
|
||||
ValidUntil = $"{x.GetDate():yyyy-MM-dd}",
|
||||
Description = x.GetString(),
|
||||
});
|
||||
|
||||
public void EditVersion(int versionId, DateTime? validUntil, string description)
|
||||
=> this.sqlConnection
|
||||
.CreateCommand($@"
|
||||
UPDATE [VersionSoftwareAccess]
|
||||
SET [SoftwareAccess_VaildTo] = @{nameof(validUntil)}
|
||||
, [SoftwareAccess_Desc] = @{nameof(description)}
|
||||
WHERE [SoftwareAccess_ID] = @{nameof(versionId)}")
|
||||
.SetParameter(nameof(versionId), versionId)
|
||||
.SetParameter(nameof(validUntil), validUntil)
|
||||
.SetParameter(nameof(description), description)
|
||||
.ExecuteNonQuery();
|
||||
|
||||
public IEnumerable<SoftwareFunction> Functions(short softwareId)
|
||||
=> this.sqlConnection
|
||||
.CreateCommand($@"
|
||||
SELECT [AppId]
|
||||
, [Id]
|
||||
, [Function]
|
||||
FROM [SoftwareFunctions]
|
||||
WHERE [AppId] = @{nameof(softwareId)}")
|
||||
.SetParameter(nameof(softwareId), softwareId)
|
||||
.ExecuteReader(x => new SoftwareFunction
|
||||
{
|
||||
SoftwareId = x.GetSmallint(),
|
||||
FunctionId = x.GetInt(),
|
||||
Function = x.GetString()
|
||||
});
|
||||
|
||||
public IEnumerable<string> GetSoftwareFunctions(string token)
|
||||
=> this.sqlConnection
|
||||
.CreateCommand($@"
|
||||
@@ -68,5 +156,29 @@
|
||||
ValidUntil = $"{x.GetDate():yyyy-MM-dd}",
|
||||
Description = x.GetString(),
|
||||
});
|
||||
|
||||
public IEnumerable<SoftwareVersion> Versions(short softwareId)
|
||||
=> this.sqlConnection
|
||||
.CreateCommand($@"
|
||||
SELECT [AppId]
|
||||
, [SoftwareAccess_Program]
|
||||
, [SoftwareAccess_ID]
|
||||
, [SoftwareAccess_MajorVersion]
|
||||
, [SoftwareAccess_MinorVersion]
|
||||
, [SoftwareAccess_BuildVersion]
|
||||
, [SoftwareAccess_VaildTo]
|
||||
, [SoftwareAccess_Desc]
|
||||
FROM [VersionSoftwareAccess]
|
||||
WHERE [AppId] = @{nameof(softwareId)}")
|
||||
.SetParameter(nameof(softwareId), softwareId)
|
||||
.ExecuteReader(x => new SoftwareVersion
|
||||
{
|
||||
SoftwareId = x.GetSmallint(),
|
||||
AssemblyName = x.GetString(),
|
||||
VersionId = x.GetInt(),
|
||||
VersionNr = $"{x.GetInt()}.{x.GetInt()}.{x.GetInt()}",
|
||||
ValidUntil = $"{x.GetDate():yyyy-MM-dd}",
|
||||
Description = x.GetString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user