示例#1
0
 private void OnTransferStarted(TransferStarted e)
 {
     lastEvent = e;
     amount    = e.Amount;
     toAccount = e.ToAccountNr;
     replyTo.Tell(new Withdraw(PersistenceId, amount));
     Become(AwaitWithdrawn);
 }
示例#2
0
        private void Handle(TransferStarted e)
        {
            var fromTxId = $"{e.TxId}[From]";
            var toTxId   = $"{e.TxId}[To]";

            SendCommand(new RecordTransaction(fromTxId, new Quantity(-e.Amount.Amount, e.Amount.Denominator), Transaction.TransactionType.Transfer, $"Transfer to {e.ToAccount}"));
            SendCommand(new AddTransaction(e.FromAccount, fromTxId));
            SendCommand(new RecordTransaction(toTxId, new Quantity(e.Amount.Amount, e.Amount.Denominator), Transaction.TransactionType.Transfer, $"Transfer from {e.FromAccount}"));
            SendCommand(new AddTransaction(e.ToAccount, toTxId));
        }
        public void Handle(TransferStarted e)
        {
            if (e.Amount > 10000)
            {
                var from  = _querySearch.SelectAccountSummary(e.FromAccount);
                var to    = _querySearch.SelectAccountSummary(e.ToAccount);
                var alert = $"Money transfer started: {e.Amount:c2} from {from.AccountCode} to {to.AccountCode}";

                // var smtp = new SmtpClient();
                // smtp.Send("*****@*****.**", "*****@*****.**", "Large Money Transfer", alert);
            }
        }
 public async Task Handle(StartTransfer startTransfer, IMessageHandlerContext context)
 {
     try
     {
         log.Info($"StartTransferHandler, TransactionId = {startTransfer.TransactionId}");
         var nHibernateSession = context.SynchronizedStorageSession.Session();
         var transactionId     = TransactionId.FromExisting(startTransfer.TransactionId);
         var fromBankAccount   = nHibernateSession.Query <BankAccount>().FirstOrDefault
                                     (x => x.BankAccountNumber.Number == startTransfer.FromBankAccountNumber) ?? BankAccount.NonExisting();
         if (fromBankAccount.DoesNotExist())
         {
             return;
         }
         var toBankAccount = nHibernateSession.Query <BankAccount>().FirstOrDefault
                                 (x => x.BankAccountNumber.Number == startTransfer.ToBankAccountNumber) ?? BankAccount.NonExisting();
         if (toBankAccount.DoesNotExist())
         {
             return;
         }
         var money            = Money.Dollars(startTransfer.Amount);
         var transactionState = TransactionStateId.STARTED;
         var now         = DateTime.UtcNow;
         var transaction = new Transaction(
             transactionId,
             fromBankAccount.BankAccountId,
             toBankAccount.BankAccountId,
             money,
             transactionState,
             now,
             now
             );
         nHibernateSession.Save(transaction);
         var transferStarted = new TransferStarted
                               (
             startTransfer.TransactionId,
             fromBankAccount.BankAccountId.Id,
             toBankAccount.BankAccountId.Id,
             startTransfer.Amount
                               );
         await context.Publish(transferStarted);
     }
     catch (Exception ex)
     {
         log.Error(ex.Message + " ** " + ex.StackTrace);
     }
 }
 public void Handle(TransferStarted c)
 {
     _store.InsertTransfer(c.IdentityTenant, c.AggregateIdentifier, c.Status.ToString(), c.FromAccount, c.ToAccount, c.Amount);
 }
 private void InitializeInstance(AccountTransferStateInstance instance, TransferStarted data)
 {
     instance.FromAccountId = data.FromAccountId;
     instance.ToAccountId   = data.ToAccountId;
     instance.Amount        = data.Amount;
 }
示例#7
0
 /// <summary>
 /// Informuje o tym, ze byl wykonany przelew i trzeba odswiezyc konta
 /// </summary>
 public void OnSendMoneyTransfer() => TransferStarted?.Invoke(this, EventArgs.Empty);
示例#8
0
        public void Handle(TransferStarted e)
        {
            var withdrawal = new WithdrawMoney(e.FromAccount, e.Amount, e.AggregateIdentifier);

            _commander.Send(withdrawal);
        }