Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="btcDepositTransactionRepository"></param>
        /// <param name="address"></param>
        /// <param name="transactionId"></param>
        /// <returns></returns>
        private static BitcoinDepositTransaction GetDepositTransaction(
            IBitcoinDepositTransactionRepository btcDepositTransactionRepository, string address, string transactionId)
        {
            try
            {
                var depositTransaction = btcDepositTransactionRepository.FindOneWhere(
                    new BitcoinDepositTransaction
                {
                    Hash      = transactionId,
                    ToAddress = address
                });
                Logger.Debug("GetDepositTransaction from DB: " + depositTransaction.ToJson());

                return(depositTransaction);
            }

            catch (Exception e)
            {
                Logger.Error(e, "GetDepositTransaction exception");
                return(null);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// CreateNewBtcDepositTransaction
 /// </summary>
 /// <param name="transactionModel"></param>
 /// <param name="transactionModelDetail"></param>
 /// <param name="btcDepositTransactionRepository"></param>
 /// <param name="currentTime"></param>
 private static void CreateNewBtcDepositTransaction(BtcTransactionModel transactionModel,
                                                    BtcTransactionDetailModel transactionModelDetail,
                                                    IBitcoinDepositTransactionRepository btcDepositTransactionRepository, long currentTime
                                                    )
 {
     try
     {
         Logger.Debug("cretateNewBtcDepositTransaction ");
         var btcDepositTransaction = new BitcoinDepositTransaction
         {
             Hash        = transactionModel.Txid,
             BlockNumber = 0,
             BlockHash   = transactionModel.BlockHash,
             Amount      = transactionModel.Amount,
             FromAddress = "",
             ToAddress   = transactionModelDetail.Address,
             Fee         = 0,
             Status      = Status.STATUS_PENDING,
             CreatedAt   = currentTime,
             UpdatedAt   = currentTime
         };
         var userId = GetUserIdByAddress(transactionModelDetail.Address);
         if (userId == null)
         {
             return;
         }
         var portfolioHistoryBusiness =
             new PortfolioHistoryBusiness.PortfolioHistoryBusiness(_persistenceFactory, false);
         portfolioHistoryBusiness.InsertWithPrice(userId);
         btcDepositTransaction.UserId = userId;
         Logger.Debug("cretateNewBtcDepositTransaction =>> btcDepositTransaction: " +
                      btcDepositTransaction.ToJson());
         btcDepositTransactionRepository.Insert(btcDepositTransaction);
     }
     catch (Exception e)
     {
         Logger.Error(e, "cretateNewBtcDepositTransaction ");
     }
 }