software index

This commit is contained in:
Stoyan Zlatev
2023-06-21 16:55:34 +02:00
parent f066fc69fb
commit bd537d0d16
30 changed files with 521 additions and 367 deletions
@@ -1,7 +1,7 @@
namespace LaaProduction.Personalization.Repositories
{
using LaaProduction.Personalization.Models;
using LaaProduction.Personalization.Repositories.Interfaces;
using LaaProductionSQL.Interfaces;
using System.Collections.Generic;
@@ -32,5 +32,41 @@
WHERE [MT].[Token] = @{nameof(token)}")
.SetParameter(nameof(token), token)
.ExecuteReader(x => x.GetString());
public IEnumerable<SoftwareItem> List()
=> this.sqlConnection
.CreateCommand($@"
SELECT [Software].[SoftwareId]
, [Software].[AssemblyName]
, [Software].[MajorV]
, [Software].[MinorV]
, [Software].[Build]
, [Software].[VersionId]
, [Software].[ValidUntil]
, [Software].[Description]
FROM (SELECT [AppID] AS [SoftwareId]
, [SoftwareAccess_Program] AS [AssemblyName]
, [SoftwareAccess_MajorVersion] AS [MajorV]
, [SoftwareAccess_MinorVersion] AS [MinorV]
, [SoftwareAccess_BuildVersion] AS [Build]
, [SoftwareAccess_ID] AS [VersionId]
, [SoftwareAccess_VaildTo] AS [ValidUntil]
, [SoftwareAccess_Desc] AS [Description]
, ROW_NUMBER()
OVER (PARTITION BY [AppID]
ORDER BY [SoftwareAccess_VaildTo] DESC) AS [RowNumber]
FROM [VersionSoftwareAccess])
AS [Software]
WHERE [Software].[RowNumber] <= 1
ORDER BY [Software].[AssemblyName]")
.ExecuteReader(x => new SoftwareItem
{
SoftwareId = x.GetSmallint(),
AssemblyName = x.GetString(),
CurrentVersion = $"{x.GetInt()}.{x.GetInt()}.{x.GetInt()}",
VersionId = x.GetInt(),
ValidUntil = $"{x.GetDate():yyyy-MM-dd}",
Description = x.GetString(),
});
}
}