예제 #1
0
        public async Task Handle(DebitAccount command)
        {
            this.log.Information($"Handling withdraw command for account {command.BankAccountId}");

            var bankAccount = await bankAccountRepository.Find(command.BankAccountId);

            bankAccount.Withdraw(command.Amount);

            await bankAccountRepository.AddOrUpdate(bankAccount);

            this.log.Information($"Withdrawed amount ${command.Amount} from bank account {command.BankAccountId}");
        }
예제 #2
0
        public async Task Handle(CreditAccount command)
        {
            this.log.Information($"Handling deposit money command for account {command.BankAccountId}");

            var bankAccount = await bankAccountRepository.Find(command.BankAccountId);

            bankAccount.Deposit(command.Amount);

            await bankAccountRepository.AddOrUpdate(bankAccount);

            this.log.Information($"Deposited amount ${command.Amount} into bank account {command.BankAccountId}");
        }
        public async Task Handle(CreateAccount command)
        {
            this.log.Information($"Handling create command for customer {command.CustomerId}");

            var customer = await customerRepository.Find(command.CustomerId);

            if (customer == null)
            {
                throw new CustomerNotFoundException(command.CustomerId);
            }

            var startingBalance = CustomerBenefits.CalculateOpeningAccountBalance(customer, command.StartingBalance);

            var newAccount = BankAccount.CreateAccount(command.CustomerId, startingBalance);

            await bankAccountRepository.AddOrUpdate(newAccount);

            this.log.Information($"Account {newAccount.Id} created for {command.CustomerId}");
        }