Ejemplo n.º 1
0
        public void Handle(AccountCreatedEvent @event)
        {
            var account = this.accountAuditCurrent.FirstOrDefault(o => o.AccountId == @event.AggregateId);

            if (account == null)
            {
                AccountAudit accAudit = new AccountAudit
                {
                    AccountId   = @event.AggregateId,
                    AccountName = @event.Name,
                    Action      = "Account Created",
                    Time        = @event.DateOccured
                };
                this.accountAuditCurrent.Add(accAudit);
            }
            else
            {
                throw new Exception(String.Format("Account does not exist! Id: {0}", @event.AggregateId));
            }
        }
Ejemplo n.º 2
0
        public void Handle(AmountWithdrawalEvent @event)
        {
            var account = this.accountAuditCurrent.FirstOrDefault(o => o.AccountId == @event.AggregateId);

            if (account != null)
            {
                AccountAudit accAudit = new AccountAudit
                {
                    AccountId   = @event.AggregateId,
                    AccountName = account.AccountName,
                    Action      = "Amount Withdrawn",
                    Time        = @event.DateOccured
                };
                this.accountAuditCurrent.Add(accAudit);
            }
            else
            {
                throw new Exception(String.Format("No account found with Id: {0}", @event.AggregateId));
            }
        }