示例#1
0
        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);
        }
示例#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);
        }
示例#3
0
        public void SelectJourneys(List <Journey> journeys)
        {
            if (journeys == null)
            {
                throw new ArgumentNullException($"{nameof(journeys)} is null");
            }

            AggregateIsNewSpecification.Create().ThrowDomainErrorIfNotSatisfied(this);

            JourneyValidationSpecification.Create().ThrowDomainErrorIfNotSatisfied(journeys);

            // Raise event
            Emit(new JourneysSelectedEvent(journeys));
        }
示例#4
0
        private bool CreateBox(CreateBoxCommand cmd)
        {
            _logger.LogHandlingCommand(cmd);
            var spec = new AggregateIsNewSpecification()
                       .And(new CreateBoxSpecification(cmd.Barcode));
            var specResult = spec.AsChessieResult(this);

            if (specResult.IsOk)
            {
                Emit(new BoxCreatedEvent(cmd.Barcode));
            }
            Sender.Tell(specResult);
            _logger.LogHandlingCommandResult(cmd, specResult);
            return(true);
        }
示例#5
0
        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);
        }