diff --git a/DBClasses.cs b/DBClasses.cs index 7836403..55171e2 100644 --- a/DBClasses.cs +++ b/DBClasses.cs @@ -36,13 +36,13 @@ namespace CryptoCalc return (long)dateTime.Subtract(DateTime.UnixEpoch).TotalSeconds; } - public DateTime GetUTCTimeFromUnixTime(long _unix) + public DateTime GetUTCTimeFromUnixTime(long unix) { - return DateTime.UnixEpoch.AddSeconds(_unix).ToUniversalTime(); - } - public DateTime GetLocalTimeFromUnixTime(long _unix) + return DateTime.UnixEpoch.AddSeconds(unix).ToUniversalTime(); + } + public DateTime GetLocalTimeFromUnixTime(long unix) { - return DateTime.UnixEpoch.AddSeconds(_unix).ToLocalTime(); + return DateTime.UnixEpoch.AddSeconds(unix).ToLocalTime(); } #endregion @@ -83,14 +83,14 @@ namespace CryptoCalc SetDBStrings(); } - public Transaction(string _currency, float _amount, string _type, string _feeCurrency, float _feeAmount) + public Transaction(string currency, float amount, string type, string feeCurrency, float feeAmount) { SaveUnixTimeNow(); - Currency = _currency; - Amount = _amount; - TransactionType = _type; - FeeCurrency = _feeCurrency; - FeeAmount = _feeAmount; + Currency = currency; + Amount = amount; + TransactionType = type; + FeeCurrency = feeCurrency; + FeeAmount = feeAmount; Platform = ""; Note = ""; @@ -114,7 +114,7 @@ namespace CryptoCalc + $"@{nameof(Note)}"; } - public string FullInfo => $"{ Index.ToString() } { GetLocalTimeFromUnixTime(UnixTime) } { Currency } { Amount } { TransactionType }"; + public string FullInfo => $"{ Index } { GetLocalTimeFromUnixTime(UnixTime) } { Currency } { Amount } { TransactionType }"; #endregion } @@ -140,16 +140,16 @@ namespace CryptoCalc public Wallet() { SetDBStrings(); } - public Wallet(int _year, int _month, int _day, string _platform, string _name, string _currency, float _balance, int _default, string _note) + public Wallet(int year, int month, int day, string platform, string name, string currency, float balance, int defaultWallet, string note) { SaveUnixTimeNow(); - UnixTimeCreated = GetUnixTime(new DateTime(_year, _month, _day)); - Platform = _platform; - Name = _name; - Currency = _currency; - Balance = _balance; - DefaultWallet = _default; - Note = _note; + UnixTimeCreated = GetUnixTime(new DateTime(year, month, day)); + Platform = platform; + Name = name; + Currency = currency; + Balance = balance; + DefaultWallet = defaultWallet; + Note = note; SetDBStrings(); } diff --git a/DBInteraction.cs b/DBInteraction.cs index 281c893..f70c1e0 100644 --- a/DBInteraction.cs +++ b/DBInteraction.cs @@ -12,15 +12,15 @@ namespace CryptoCalc public class DBInteraction { - public static void SaveData(ref T _data) where T : DBClasses + public static void SaveData(ref T data) where T : DBClasses { - if (_data is null) + if (data is null) { - throw new ArgumentNullException(nameof(_data)); + throw new ArgumentNullException(nameof(data)); } - using IDbConnection cnn = new SQLiteConnection(Util.GetConnectionString(_data.DBTableName)); - cnn.Execute($"insert into {_data.DBTableName} {_data.DBSaveDataString}", _data); - Debug.WriteLine($"Saved {_data.DBTableName} DB data"); + using IDbConnection cnn = new SQLiteConnection(Util.GetConnectionString(data.DBTableName)); + cnn.Execute($"insert into {data.DBTableName} {data.DBSaveDataString}", data); + Debug.WriteLine($"Saved {data.DBTableName} DB data"); } //public static List _LoadTransactions() @@ -35,17 +35,23 @@ namespace CryptoCalc public static List LoadTransactions() { using IDbConnection _connection = new SQLiteConnection(Util.GetConnectionString("Transactions")); - var output = _connection.Query("select * from Transactions", new DynamicParameters()); + IEnumerable output = _connection.Query("select * from Transactions", new DynamicParameters()); Debug.WriteLine("Loaded DB data"); return output.ToList(); - } - + } - public static List LoadTransactionsOfCurrency(string _currency) + + public static List LoadTransactionsOfCurrency(string currency) { - Debug.WriteLine($"Fetching all {_currency} transactions from Database"); + if (currency is null) + { + throw new ArgumentNullException(nameof(currency)); + } + + Debug.WriteLine($"Fetching all {currency} transactions from Database"); using IDbConnection connection = new SQLiteConnection(Util.GetConnectionString("Transactions")); - return connection.Query($"select * from Transactions where Currency = '{ _currency.ToUpper() }'").ToList(); + return connection.Query($"select * from Transactions where Currency = '{ currency.ToUpper() }'") + .ToList(); } } }