Example #1
0
            public void Transfer(string fromAccountId, string toAccountId, decimal amount)
            {
                _logger.BeginScope(Guid.NewGuid().ToString());
                var fromAmount = _accountDal.GetBalance(fromAccountId);
                var toAmount   = _accountDal.GetBalance(toAccountId);

                fromAmount -= amount;
                toAmount   += amount;
                _accountDal.UpdateBalance(fromAccountId, fromAmount);
                _accountDal.UpdateBalance(toAccountId, toAmount);
            }
Example #2
0
            public void Transfer(string fromAccountId, string toAccountId, decimal amount)
            {
                Console.WriteLine("Transfer function logger hashcode: " + _logger.GetHashCode());
                _logger.DefineScope(Guid.NewGuid().ToString());
                decimal fromAmount = _accountDal.GetBalance(fromAccountId);
                decimal toAmount   = _accountDal.GetBalance(toAccountId);

                fromAmount -= amount;
                toAmount   += amount;
                _accountDal.UpdateBalance(fromAccountId, fromAmount);
                _accountDal.UpdateBalance(toAccountId, toAmount);
            }
Example #3
0
 public void Transfer(string fromAccountId, string toAccountId, decimal amount)
 {
     using (var dbConnection = _dbFactory.CreateDbConnection())
     {
         using (var transaction = dbConnection.BeginTransaction())
         {
             try
             {
                 var fromAmount = _accountDal.GetBalance(fromAccountId);
                 var toAmount   = _accountDal.GetBalance(toAccountId);
                 fromAmount -= amount;
                 toAmount   += amount;
                 _accountDal.UpdateBalance(fromAccountId, fromAmount);
                 _accountDal.UpdateBalance(toAccountId, toAmount);
                 transaction.Commit();
             }
             catch (Exception)
             {
                 transaction.Rollback();
                 throw;
             }
         }
     }
 }