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); }
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 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)); }
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); }
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); }