Пример #1
0
 internal WalletTransaction(Decimal amount, ICommand command)
 {
     Id       = Guid.NewGuid();
     Amount   = amount;
     _command = command;
     Status   = WalletTransactionStatus.Pending;
 }
Пример #2
0
 public void Initiate()
 {
     if (Status != WalletTransactionStatus.Pending)
     {
         throw new InvalidOperationException($"Unable to initiate transaction {Id}.");
     }
     try
     {
         _command.Execute();
     }
     catch (Exception exception)
     {
         Status = WalletTransactionStatus.Failed;
         throw new TransactionExecutionException(exception);
     }
     Status = WalletTransactionStatus.Completed;
 }
Пример #3
0
        public void Revert()
        {
            if (Status != WalletTransactionStatus.Completed)
            {
                throw new InvalidOperationException($"Unable to invert transaction {Id}.");
            }

            try
            {
                _command.Revert();
            }
            catch (Exception exception)
            {
                Status = WalletTransactionStatus.RevertFailed;
                throw new TransactionRevertException(exception);
            }

            Status = WalletTransactionStatus.Reverted;
        }