diff --git a/App.config b/App.config index 924c79d..e124558 100644 --- a/App.config +++ b/App.config @@ -1,8 +1,6 @@  - - - + \ No newline at end of file diff --git a/DBClasses.cs b/DBClasses.cs index ccb3af4..88e1ff8 100644 --- a/DBClasses.cs +++ b/DBClasses.cs @@ -6,21 +6,24 @@ namespace CryptoCalc public interface IDBClasses { - string DBVariables { get; set; } + string DBName { get; } string DBTableName { get; } + string DBVariables { get; set; } string DBSaveDataString { get; } } public class DBClasses : IDBClasses { #region Publics - public virtual string DBVariables { get; set; } + public string DBName => "CryptoCalc"; public virtual string DBTableName { get; } + public virtual string DBVariables { get; set; } public string DBSaveDataString => $"({Regex.Replace(DBVariables, "@", "")}) values ({DBVariables})"; public int Index { get; set; } public long UnixTime { get; set; } + #endregion #region Functions diff --git a/DBInteraction.cs b/DBInteraction.cs index 3a6eac9..4d27355 100644 --- a/DBInteraction.cs +++ b/DBInteraction.cs @@ -14,10 +14,10 @@ namespace CryptoCalc { if (data is null) { - throw new ArgumentNullException(nameof(data)); + throw new ArgumentNullException(nameof(data), "No data passed to SQL"); } - using IDbConnection cnn = new SQLiteConnection(Util.GetConnectionString(data.DBTableName)); + using IDbConnection cnn = new SQLiteConnection(Util.GetConnectionString(data.DBName)); cnn.Execute($"insert into {data.DBTableName} {data.DBSaveDataString}", data); Debug.WriteLine($"Saved {data.DBTableName} DB data"); } @@ -25,26 +25,14 @@ namespace CryptoCalc public class GenericDB where T : DBClasses { - - public IEnumerable LoadAllData(string tableName) + public IEnumerable QueryData(T data, string query) { - if (tableName is null) + if (data is null) { - throw new ArgumentNullException(nameof(tableName)); + throw new ArgumentNullException(nameof(data), "DBclass is null"); } - using IDbConnection _connection = new SQLiteConnection(Util.GetConnectionString(tableName)); - return _connection.Query($"select * from {tableName}", new DynamicParameters()); - } - - public IEnumerable QueryData(string tableName, string query) - { - if (tableName is null) - { - throw new ArgumentNullException(nameof(query)); - } - - using IDbConnection _connection = new SQLiteConnection(Util.GetConnectionString(tableName)); + using IDbConnection _connection = new SQLiteConnection(Util.GetConnectionString(data.DBName)); return _connection.Query($"{query}", new DynamicParameters()); } } diff --git a/MainWindow.xaml b/MainWindow.xaml index a369759..02c105a 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -14,7 +14,7 @@