using System; using System.Text.RegularExpressions; namespace CryptoCalc { public interface IDBClasses { string dbVariables { get; set; } string variables { get; set; } string DBTableName { get; } string DBVariables { get; } } public class DB_Classes : IDBClasses { public virtual string dbVariables { get; set ; } public virtual string variables { get; set; } public virtual string DBTableName => throw new NotImplementedException(); public string DBVariables => $"({variables}) values ({dbVariables})"; public int Index { get; set; } public int Year { get; set; } public int Month { get; set; } public int Day { get; set; } public int Hour { get; set; } public int Minute { get; set; } public int Second { get; set; } public string DateTimeString { get; set; } } public class Transaction : DB_Classes { #region Publics public override string dbVariables { get => base.dbVariables; set => base.dbVariables = value; } public override string variables { get => base.variables; set => base.variables = value; } public override string DBTableName => "Transactions"; public string Currency { get; set; } public float Amount { get; set; } public string TransactionType { get; set; } public string FeeCurrency { get; set; } public float FeeAmount { get; set; } public string Platform { get; set; } public string Note { get; set; } #endregion #region Constructors public Transaction() { SetDBStrings(); } public Transaction(string _currency, float _amount, string _type) { Year = DateTime.Now.Year; Month = DateTime.Now.Month; Day = DateTime.Now.Day; Hour = DateTime.Now.Hour; Minute = DateTime.Now.Minute; Second = DateTime.Now.Second; DateTimeString = DateTime.Now.ToString(); Currency = _currency; Amount = _amount; TransactionType = _type; Platform = ""; Note = ""; SetDBStrings(); } public Transaction(string _currency, float _amount, string _type, string _feeCurrency, float _feeAmount) { Year = DateTime.Now.Year; Month = DateTime.Now.Month; Day = DateTime.Now.Day; Hour = DateTime.Now.Hour; Minute = DateTime.Now.Minute; Second = DateTime.Now.Second; DateTimeString = DateTime.Now.ToString(); Currency = _currency; Amount = _amount; TransactionType = _type; FeeCurrency = _feeCurrency; FeeAmount = _feeAmount; Platform = ""; Note = ""; SetDBStrings(); } #endregion #region Functions void SetDBStrings() { dbVariables = $"@{nameof(Year)}, " + $" @{nameof(Month)}," + $" @{nameof(Day)}," + $" @{nameof(Hour)}," + $" @{nameof(Minute)}," + $" @{nameof(Second)}," + $" @{nameof(DateTimeString)}," + $" @{nameof(Currency)}," + $" @{nameof(Amount)}," + $" @{nameof(TransactionType)}," + $" @{nameof(FeeCurrency)}," + $" @{nameof(FeeAmount)}," + $" @{nameof(Platform)}," + $" @{nameof(Note)}"; variables = Regex.Replace(dbVariables, "@", ""); } public string FullInfo => $"{ Index.ToString() } { DateTimeString } { Currency } { Amount } { TransactionType }"; #endregion } public class Wallet : DB_Classes { #region Publics public override string dbVariables { get => base.dbVariables; set => base.dbVariables = value; } public override string variables { get => base.variables; set => base.variables = value; } public override string DBTableName => "Wallets"; public int CreationYear { get; set; } public int CreationMonth { get; set; } public int CreationDay { get; set; } public string Platform { get; set; } public string Name { get; set; } public string Currency { get; set; } public float Balance { get; set; } public int DefaultWallet { get; set; } public string Notes { get; set; } #endregion #region Constructors public Wallet() { SetDBStrings(); } public Wallet(int _year, int _month, int _day, string _platform, string _name, string _currency, float _balance, int _default, string _note) { CreationYear = _year; CreationMonth = _month; CreationDay = _day; Platform = _platform; Name = _name; Currency = _currency; Balance = _balance; DefaultWallet = _default; Notes = _note; SetDBStrings(); } #endregion #region Functions void SetDBStrings() { dbVariables = $"@{nameof(Year)}, " + $" @{nameof(Month)}," + $" @{nameof(Day)}," + $" @{nameof(Hour)}," + $" @{nameof(Minute)}," + $" @{nameof(Second)}," + $" @{nameof(DateTimeString)}," + $" @{nameof(CreationYear)}," + $" @{nameof(CreationMonth)}," + $" @{nameof(CreationDay)}," + $" @{nameof(Platform)}," + $" @{nameof(Name)}," + $" @{nameof(Currency)}," + $" @{nameof(Balance)}," + $" @{nameof(DefaultWallet)}," + $" @{nameof(Notes)}"; variables = Regex.Replace(dbVariables, "@", ""); } //public string FullInfo => $"{ Index.ToString() } { DateTimeString } { Currency } { Amount } { TransactionType }"; #endregion } /* public class RawData : DB_Classes { #region Publics public override string DBTableName => "RawData"; //public override string DBVariables => "(Date_Year, Date_Month, Date_Day, Time_Hour, Time_Minute, Time_Second, DateTimeString, CryptoCurrency, Amount, TransactionType, Service, Comment) values (@Date_Year, @Date_Month, @Date_Day, @Time_Hour, @Time_Minute, @Time_Second, @DateTimeString, @CryptoCurrency, @Amount, @TransactionType, @Service, @Comment)"; public string CryptoCurrency { get; set; } public float Amount { get; set; } public string TransactionType { get; set; } public string Service { get; set; } public string Comment { get; set; } #endregion #region Contructors public RawData() { } public RawData(string _currency, float _amount, string _type) { Year = DateTime.Now.Year; Month = DateTime.Now.Month; Day = DateTime.Now.Day; Hour = DateTime.Now.Hour; Minute = DateTime.Now.Minute; Second = DateTime.Now.Second; DateTimeString = DateTime.Now.ToString(); CryptoCurrency = _currency; Amount = _amount; TransactionType = _type; Service = ""; Comment = ""; dbVariables = $"@{nameof(Year)}, " + $" @{nameof(Month)}," + $" @{nameof(Day)}," + $" @{nameof(Hour)}," + $" @{nameof(Minute)}," + $" @{nameof(Second)}," + $" @{nameof(DateTimeString)}," + $" @{nameof(tCurrency)}," + $" @{nameof(tAmount)}," + $" @{nameof(tTransactionType)}," + $" @{nameof(tFeeCurrency)}," + $" @{nameof(tFeeAmount)}," + $" @{nameof(tPlatform)}," + $" @{nameof(tNote)}"; variables = Regex.Replace(dbVariables, "@", ""); } #endregion #region Functions public string FullInfo => $"{ Index.ToString() } { DateTimeString } { CryptoCurrency } { Amount } { TransactionType }"; #endregion } */ }