2021-09-15 16:21:04 +02:00

72 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using DigitalData.Modules.Database;
using Microsoft.Extensions.Configuration;
namespace ChangeloggerMVC
{
public class Database : IDatabase
{
public MSSQLServer MSSQL { get; set; }
public Database(ILogging Logging, IConfiguration Config)
{
var LogConfig = Logging.LogConfig;
var Logger = Logging.LogConfig.GetLogger();
var AppConfig = Config.GetSection("Config");
var FBConfig = AppConfig.GetSection("Firebird");
MSSQL = new MSSQLServer(LogConfig, AppConfig["MSSQLConnectionString"]);
Logger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentSQLConnectionString);
}
public Dictionary<int, string> GetProducts()
{
var oResult = new Dictionary<int, string>();
DataTable oTable = MSSQL.GetDatatable("SELECT * FROM TBPRODUCT");
foreach (DataRow dataRow in oTable.Rows)
{
oResult.Add((int)dataRow["GUID"], (string)dataRow["TITLE"]);
}
return oResult;
}
public Dictionary<int, string> GetModules()
{
var oResult = new Dictionary<int, string>();
DataTable oTable = MSSQL.GetDatatable("SELECT * FROM TBMODULE");
foreach (DataRow dataRow in oTable.Rows)
{
oResult.Add((int)dataRow["GUID"], (string)dataRow["TITLE"]);
}
return oResult;
}
public Dictionary<int, string> GetTypes()
{
var oResult = new Dictionary<int, string>();
DataTable oTable = MSSQL.GetDatatable("SELECT * FROM TBCHANGE_LOG_TYPE");
foreach (DataRow dataRow in oTable.Rows)
{
oResult.Add((int)dataRow["GUID"], (string)dataRow["TITLE"]);
}
return oResult;
}
}
}