Exemplo n.º 1
0
        public ICredit Deposit(IAccountFactory entityFactory, PositiveMoney amountToDeposit)
        {
            var credit = entityFactory.NewCredit(this, amountToDeposit, DateTime.UtcNow);

            Credits.Add(credit);
            return(credit);
        }
        private async Task OpenAccount(Money amountToDeposit)
        {
            var customerId = _customerService.GetCurrentCustomerId();
            var account    = _accountFactory.NewAccount(customerId, amountToDeposit.Currency);
            var credit     = _accountFactory.NewCredit(account, amountToDeposit, DateTime.UtcNow);

            await Deposit(account, credit);

            _outputPort?.Ok(account);
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public ICredit Deposit(IAccountFactory entityFactory, PositiveMoney amountToDeposit)
        {
            if (entityFactory is null)
            {
                throw new ArgumentNullException(nameof(entityFactory));
            }

            var credit = entityFactory.NewCredit(this, amountToDeposit, DateTime.UtcNow);

            this.Credits.Add(credit);
            return(credit);
        }
        private async Task DepositAsync(AccountId accountId, Money amount)
        {
            var account = await _accountRepository.Get(accountId);

            if (account is Account depositAccount)
            {
                var convertedAmount = await _currencyExchanger.Convert(amount, depositAccount.Currency);

                var credit = _accountFactory.NewCredit(depositAccount, convertedAmount, DateTime.UtcNow);

                await DepositAsync(depositAccount, credit);

                _outputPort?.Ok(credit, depositAccount);
                return;
            }

            _logger.LogWarning($"{nameof(DepositAsync)} Account not found {accountId}");
        }