예제 #1
0
        public void Handle(PayDepositCommand payDepositCommand)
        {
            var paymentId = PaymentId.From(payDepositCommand.AgreementId);
            var payment   = _paymentRepository.Get(paymentId);
            var accountId = AccountOwnerId.From(payDepositCommand.TenantId);
            var title     = Title.From("Deposit payment");

            _paymentService.PayDeposit(accountId, title, payment, paymentId);
        }
        public void PayDeposit(AccountOwnerId accountId, Title title, Domain.Payment.Payment payment, PaymentId paymentId)
        {
            if (_balanceService.HasFounds(accountId, payment.Money))
            {
                payment.Pay(title);
                return;
            }

            _eventRegistry.Publish(new InsufficientFundsNoticed(accountId.ToString(), paymentId.ToString()));
        }
        public void Handle(DraftAccepted draftAccepted)
        {
            var sourceAccountOwnerId      = AccountOwnerId.From(draftAccepted.TenantId);
            var destinationAccountOwnerId = AccountOwnerId.From(draftAccepted.OwnerId);
            var sourceAccount             = _accountRepository.Get(sourceAccountOwnerId);
            var destinationAccount        = _accountRepository.Get(destinationAccountOwnerId);
            var money = Money.From(draftAccepted.Price);
            var title = Title.ToTransferTitle(draftAccepted.AgreementNumber);

            _transferMoneyService.Transfer(sourceAccount, destinationAccount, money, title);
        }
예제 #4
0
        public bool HasFounds(AccountOwnerId accountOwnerId, Money money)
        {
            var account = _accountRepository.Get(accountOwnerId);

            return(account.HasFounds(money));
        }
예제 #5
0
 public Account(AccountOwnerId accountOwnerId)
 {
     _accountOwnerId = accountOwnerId;
 }