CA1707: Identifiers should not contain underscores
This commit is contained in:
parent
4750ce7351
commit
9cb7df5dec
38
DBClasses.cs
38
DBClasses.cs
|
@ -36,13 +36,13 @@ namespace CryptoCalc
|
||||||
return (long)dateTime.Subtract(DateTime.UnixEpoch).TotalSeconds;
|
return (long)dateTime.Subtract(DateTime.UnixEpoch).TotalSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime GetUTCTimeFromUnixTime(long _unix)
|
public DateTime GetUTCTimeFromUnixTime(long unix)
|
||||||
{
|
{
|
||||||
return DateTime.UnixEpoch.AddSeconds(_unix).ToUniversalTime();
|
return DateTime.UnixEpoch.AddSeconds(unix).ToUniversalTime();
|
||||||
}
|
}
|
||||||
public DateTime GetLocalTimeFromUnixTime(long _unix)
|
public DateTime GetLocalTimeFromUnixTime(long unix)
|
||||||
{
|
{
|
||||||
return DateTime.UnixEpoch.AddSeconds(_unix).ToLocalTime();
|
return DateTime.UnixEpoch.AddSeconds(unix).ToLocalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -83,14 +83,14 @@ namespace CryptoCalc
|
||||||
SetDBStrings();
|
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();
|
SaveUnixTimeNow();
|
||||||
Currency = _currency;
|
Currency = currency;
|
||||||
Amount = _amount;
|
Amount = amount;
|
||||||
TransactionType = _type;
|
TransactionType = type;
|
||||||
FeeCurrency = _feeCurrency;
|
FeeCurrency = feeCurrency;
|
||||||
FeeAmount = _feeAmount;
|
FeeAmount = feeAmount;
|
||||||
Platform = "";
|
Platform = "";
|
||||||
Note = "";
|
Note = "";
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ namespace CryptoCalc
|
||||||
+ $"@{nameof(Note)}";
|
+ $"@{nameof(Note)}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string FullInfo => $"{ Index.ToString() } { GetLocalTimeFromUnixTime(UnixTime) } { Currency } { Amount } { TransactionType }";
|
public string FullInfo => $"{ Index } { GetLocalTimeFromUnixTime(UnixTime) } { Currency } { Amount } { TransactionType }";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -140,16 +140,16 @@ namespace CryptoCalc
|
||||||
|
|
||||||
public Wallet() { SetDBStrings(); }
|
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();
|
SaveUnixTimeNow();
|
||||||
UnixTimeCreated = GetUnixTime(new DateTime(_year, _month, _day));
|
UnixTimeCreated = GetUnixTime(new DateTime(year, month, day));
|
||||||
Platform = _platform;
|
Platform = platform;
|
||||||
Name = _name;
|
Name = name;
|
||||||
Currency = _currency;
|
Currency = currency;
|
||||||
Balance = _balance;
|
Balance = balance;
|
||||||
DefaultWallet = _default;
|
DefaultWallet = defaultWallet;
|
||||||
Note = _note;
|
Note = note;
|
||||||
|
|
||||||
SetDBStrings();
|
SetDBStrings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,15 +12,15 @@ namespace CryptoCalc
|
||||||
public class DBInteraction
|
public class DBInteraction
|
||||||
{
|
{
|
||||||
|
|
||||||
public static void SaveData<T>(ref T _data) where T : DBClasses
|
public static void SaveData<T>(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));
|
using IDbConnection cnn = new SQLiteConnection(Util.GetConnectionString(data.DBTableName));
|
||||||
cnn.Execute($"insert into {_data.DBTableName} {_data.DBSaveDataString}", _data);
|
cnn.Execute($"insert into {data.DBTableName} {data.DBSaveDataString}", data);
|
||||||
Debug.WriteLine($"Saved {_data.DBTableName} DB data");
|
Debug.WriteLine($"Saved {data.DBTableName} DB data");
|
||||||
}
|
}
|
||||||
|
|
||||||
//public static List<T> _LoadTransactions()
|
//public static List<T> _LoadTransactions()
|
||||||
|
@ -35,17 +35,23 @@ namespace CryptoCalc
|
||||||
public static List<Transaction> LoadTransactions()
|
public static List<Transaction> LoadTransactions()
|
||||||
{
|
{
|
||||||
using IDbConnection _connection = new SQLiteConnection(Util.GetConnectionString("Transactions"));
|
using IDbConnection _connection = new SQLiteConnection(Util.GetConnectionString("Transactions"));
|
||||||
var output = _connection.Query<Transaction>("select * from Transactions", new DynamicParameters());
|
IEnumerable<Transaction> output = _connection.Query<Transaction>("select * from Transactions", new DynamicParameters());
|
||||||
Debug.WriteLine("Loaded DB data");
|
Debug.WriteLine("Loaded DB data");
|
||||||
return output.ToList();
|
return output.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static List<Transaction> LoadTransactionsOfCurrency(string _currency)
|
public static List<Transaction> 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"));
|
using IDbConnection connection = new SQLiteConnection(Util.GetConnectionString("Transactions"));
|
||||||
return connection.Query<Transaction>($"select * from Transactions where Currency = '{ _currency.ToUpper() }'").ToList();
|
return connection.Query<Transaction>($"select * from Transactions where Currency = '{ currency.ToUpper() }'")
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue