public async Task <ResultCode> SaveOutTxAsync(string address, decimal amount) { using (dbContext) using (var tran = dbContext.Database.BeginTransaction()) { try { var walletRepo = new WalletRepository(); var wallet = await walletRepo.FindByAddressAsync(address); var outTx = new OutTransaction { Address = address, Amount = amount, TimeStamp = DateTime.Now, WalletId = wallet?.Id ?? 0 }; dbContext.OutTransactions.Add(outTx); await dbContext.SaveChangesAsync(); tran.Commit(); return(ResultCode.Ok); } catch (Exception ex) { Debug.WriteLine(ex); tran?.Rollback(); return(ResultCode.Error); } } }
public NewOutTransactionRecorded(Guid fromAccountId, Guid toAccountId, OutTransaction outflow) { FromAccountId = fromAccountId; ToAccountId = toAccountId; Outflow = outflow; EventType = EventType.TransferOutcome; }
private async Task StoreTransaction(OutTransaction transaction) { await SqlExecutor.ExecuteStoreProcedureScalar(_configuration.ConnectionString, "OutTransactions_Store", new[] { new SqlParameter("@TxId", transaction.TxId), new SqlParameter("@Amount", transaction.Amount), new SqlParameter("@Address", transaction.Address), new SqlParameter("@TimeReceived", transaction.TimeReceived), new SqlParameter("@Confirmations", transaction.Confirmations), new SqlParameter("@FromWallet", transaction.FromWallet) }); }
public async Task SaveAsync(OutTransaction outTransaction) { await _bitcoinAppContext.OutTransactions.AddAsync(outTransaction); _bitcoinAppContext.SaveChanges(); }
public OutTransaction ConvertFromDB(SqlDataReader reader) { OutTransaction t = new OutTransaction(); t.Id = reader.GetInt32(reader.GetOrdinal("Id")); if (!reader.IsDBNull(reader.GetOrdinal("Direction"))) { t.Direction = reader.GetString(reader.GetOrdinal("Direction")); } if (!reader.IsDBNull(reader.GetOrdinal("Price"))) { t.Price = reader.GetDouble(reader.GetOrdinal("Price")); } if (!reader.IsDBNull(reader.GetOrdinal("Size"))) { t.Size = reader.GetInt32(reader.GetOrdinal("Size")); } if (!reader.IsDBNull(reader.GetOrdinal("Message"))) { t.Message = reader.GetString(reader.GetOrdinal("Message")); } if (!reader.IsDBNull(reader.GetOrdinal("Fee"))) { t.Fee = reader.GetDouble(reader.GetOrdinal("Fee")); } if (!reader.IsDBNull(reader.GetOrdinal("TradingDate"))) { t.TradingDate = reader.GetInt32(reader.GetOrdinal("TradingDate")); } if (!reader.IsDBNull(reader.GetOrdinal("ModifiedBy"))) { t.ModifiedBy = reader.GetString(reader.GetOrdinal("ModifiedBy")); } if (!reader.IsDBNull(reader.GetOrdinal("ModifiedDate"))) { t.CreateDate = reader.GetDateTime(reader.GetOrdinal("ModifiedDate")); } if (!reader.IsDBNull(reader.GetOrdinal("ShareId"))) { t.ShareId = reader.GetInt32(reader.GetOrdinal("ShareId")); } if (!reader.IsDBNull(reader.GetOrdinal("Symbol"))) { t.Symbol = reader.GetString(reader.GetOrdinal("Symbol")); } if (!reader.IsDBNull(reader.GetOrdinal("OrderId"))) { t.OrderId = reader.GetInt32(reader.GetOrdinal("OrderId")); } t.TotalValue = t.Price * Math.Abs(t.Size); return(t); }