예제 #1
0
        public void Can_create_DeposeCheque_Command()
        {
            var id       = Guid.NewGuid();
            var funds    = 250;
            var @command = new DeposeCheque(id, funds);

            Assert.NotNull(@command);
            Assert.Equal(id, @command.AccountId);
            Assert.Equal(funds, @command.Funds);
        }
예제 #2
0
        public CommandResponse Handle(DeposeCheque command)
        {
            //how to make it async and also implement the interface?
            if (!_repository.TryGetById <AccountAggregate.BankAccount>(command.AccountId, out var account))
            {
                throw new InvalidOperationException("No account with such ID");
            }
            account.DeposeCheque(command.Funds, new DeposedCheque(command.AccountId, command.Funds)).Wait();
            _repository.Save(account);

            return(command.Succeed());
        }