public bool Handle(IDomainEvent <Account, AccountId, MoneyReceivedEvent> domainEvent)
        {
            var spec = new AggregateIsNewSpecification().Not();

            if (spec.IsSatisfiedBy(this))
            {
                Emit(new MoneyTransferCompletedEvent(domainEvent.AggregateEvent.Transaction));
            }

            return(true);
        }
Exemple #2
0
        private bool Execute(OpenNewAccountCommand command)
        {
            //this spec is part of Akkatecture
            var spec = new AggregateIsNewSpecification();

            if (spec.IsSatisfiedBy(this))
            {
                var aggregateEvent = new AccountOpenedEvent(command.OpeningBalance);
                Emit(aggregateEvent);
            }

            return(true);
        }
        public bool Handle(IDomainEvent <Account, AccountId, MoneySentEvent> domainEvent)
        {
            var isNewSpec = new AggregateIsNewSpecification();

            if (isNewSpec.IsSatisfiedBy(this))
            {
                var command = new ReceiveMoneyCommand(
                    domainEvent.AggregateEvent.Transaction.Receiver,
                    domainEvent.AggregateEvent.Transaction);

                AccountAggregateManager.Tell(command);

                Emit(new MoneyTransferStartedEvent(domainEvent.AggregateEvent.Transaction));
            }

            return(true);
        }