コード例 #1
0
        public async Task Process(DepositInput input)
        {
            Account account = await accountReadOnlyRepository.Get(input.AccountId);

            if (account == null)
            {
                throw new AccountNotFoundException($"The account {input.AccountId} does not exists or is already closed.");
            }

            Credit credit = new Credit(account.Id, input.Amount);

            account.Deposit(credit);

            await accountWriteOnlyRepository.Update(account, credit);

            TransactionOutput transactionResponse = outputConverter.Map <TransactionOutput>(credit);
            DepositOutput     output = new DepositOutput(transactionResponse, account.GetCurrentBalance().Value);

            outputBoundary.Populate(output);
        }
コード例 #2
0
        public async Task <DepositOutput> Execute(Guid accountId, Amount amount)
        {
            Account account = await _accountReadOnlyRepository.Get(accountId);

            if (account == null)
            {
                throw new AccountNotFoundException($"The account {accountId} does not exists or is already closed.");
            }

            account.Deposit(amount);
            Credit credit = (Credit)account.GetLastTransaction();

            await _accountWriteOnlyRepository.Update(account, credit);

            DepositOutput output = new DepositOutput(
                credit,
                account.GetCurrentBalance());

            return(output);
        }