Exemplo n.º 1
0
        private bool Execute(TransferMoneyCommand command)
        {
            var balanceSpec         = new EnoughBalanceAmountSpecification();
            var minimumTransferSpec = new MinimumTransferAmountSpecification();

            var andSpec = balanceSpec.And(minimumTransferSpec);

            if (andSpec.IsSatisfiedBy(this))
            {
                var sentEvent = new MoneySentEvent(command.Transaction);
                Emit(sentEvent);

                var feeEvent = new FeesDeductedEvent(new Money(0.25m));
                Emit(feeEvent);
            }

            return(true);
        }
 public void Apply(MoneySentEvent aggregateEvent)
 {
     Balance -= aggregateEvent.Transaction.Amount;
 }