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 GetProducts() { var oResult = new Dictionary(); 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 GetModules() { var oResult = new Dictionary(); 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 GetTypes() { var oResult = new Dictionary(); 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; } } }