public void Execute(Guid fromAccountId, Guid toAccountId, decimal amount)
        {
            var to = this.accountRepository.GetAccountById(toAccountId);

            withdrawMoney.Execute(fromAccountId, amount);

            to.Pay(amount);

            if (to.CheckPayInLimit())
            {
                this.notificationService.NotifyApproachingPayInLimit(to.User.Email);
            }

            this.accountRepository.Update(to);
        }
Example #2
0
        public void Execute(Guid fromAccountId, Guid toAccountId, decimal amount)
        {
            WithdrawMoney withdraw = new WithdrawMoney(accountRepository, notificationService);

            withdraw.Execute(fromAccountId, amount);
            var to = this.accountRepository.GetAccountById(toAccountId);

            var paidIn = to.PaidIn + amount;

            if (Account.ValidateLessThanLimit(paidIn))
            {
                throw new InvalidOperationException("Account pay in limit reached");
            }
            var Balance = Account.PayInLimit - paidIn;

            if (Account.ValidateLowFunds(Balance))
            {
                this.notificationService.NotifyApproachingPayInLimit(to.User.Email);
            }

            to.Balance = to.Balance + amount;
            to.PaidIn  = to.PaidIn + amount;
            this.accountRepository.Update(to);
        }