示例#1
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);
        }
 public TransferMoney(IAccountRepository accountRepository, INotificationService notificationService)
 {
     this.accountRepository   = accountRepository;
     this.notificationService = notificationService;
     withdrawMoney            = new WithdrawMoney(accountRepository, notificationService);
 }