Example #1
0
        public void AddTransaction(CustomerTransaction customerTransaction)
        {
            using (var transaction = new TransactionScope())
            using (var connection = new ConnectionScope())
            {
                var customer = GetCustomer(customerTransaction.CustomerId);
                if (customer == null)
                    throw new Exception("Customer not found");

                customerTransaction.Insert();
                customer.Balance += customerTransaction.Amount;
                customer.Update();

                transaction.Complete();
            }
        }