コード例 #1
0
        protected void UpdateTransactions <TDbTransactionModel>(IDalContext context,
                                                                List <GetTransactionResponse> transactions, string category,
                                                                Func <IDalContext, List <TDbTransactionModel> > funcGetDbTransactions,
                                                                Action <HotWalletModel, TransactionElement> actionAddTransactionInDb)
            where TDbTransactionModel : TransactionModel
        {
            long time;
            var  dictionaryRpcTransactions = new Dictionary <string, List <TransactionElement> >();

            transactions.ForEach(transaction =>
            {
                var detailTransaction = transaction.Details.First(d =>
                                                                  string.Compare(d.Category, category, StringComparison.OrdinalIgnoreCase) == 0);
                time       = GetTransactionTime(transaction, category);
                var result = new TransactionElement(transaction.TxId, transaction.Confirmations, time,
                                                    detailTransaction.Account, detailTransaction.Address, Convert.ToSingle(detailTransaction.Amount));
                if (!dictionaryRpcTransactions.ContainsKey(detailTransaction.Address))
                {
                    dictionaryRpcTransactions[result.Address] = new List <TransactionElement>();
                }
                dictionaryRpcTransactions[result.Address].Add(result);
            });
            var updateDbTransactionsIds =
                UpdateDbTransactions(context, dictionaryRpcTransactions, funcGetDbTransactions);

            AddTransactionsInDb(context, dictionaryRpcTransactions, updateDbTransactionsIds, actionAddTransactionInDb);
        }
コード例 #2
0
 protected void AddOutgoingTransactionInDb(HotWalletModel dbWallet, TransactionElement localTransaction)
 {
     dbWallet.OutgoingTransactions.Add(new OutgoingTransactionModel
     {
         TxId            = localTransaction.TxId,
         Account         = localTransaction.Account,
         Address         = localTransaction.Address,
         Amount          = localTransaction.Amount,
         Confirmations   = localTransaction.Confirmations,
         TimeTransaction = localTransaction.Time,
     });
 }