Exemple #1
0
        public void Can_create_SetWireTransferLimit_Command()
        {
            var id       = Guid.NewGuid();
            var limit    = 250;
            var @command = new SetWireTransferLimit(id, limit);

            Assert.NotNull(@command);
            Assert.Equal(id, @command.AccountId);
            Assert.Equal(limit, @command.Limit);
        }
        public CommandResponse Handle(SetWireTransferLimit command)
        {
            if (!_repository.TryGetById <AccountAggregate.BankAccount>(command.AccountId, out var account))
            {
                throw new InvalidOperationException("No account with such ID");
            }
            account.SetDailyWireTransferLimit(command.Limit, new SettedWireTransferLimit(command.AccountId, command.Limit));
            _repository.Save(account);

            return(command.Succeed());
        }