Esempio n. 1
0
        public async Task <Transaction> Deposit(CurrentAccount currentAccount, decimal amount)
        {
            var transaction = new Transaction(currentAccount.Id, TransactionType.Deposit, amount);

            _currentAccountRepository.CreateTransaction(transaction);

            currentAccount.CurrentBalance += amount;

            _currentAccountRepository.Update(currentAccount);

            await _currentAccountRepository.UnitOfWork.Commit();

            return(transaction);
        }
Esempio n. 2
0
        public async Task <IActionResult> OnPostDeposit()
        {
            if (!ValidatorOperations() || await CurrentAccount())
            {
                await OnGet();

                return(Page());
            }

            Movement.CurrentAccountId = _current.Id;
            Movement.CurrentAccount   = _current;
            Movement.Deposit(Movement.ValueMovement);
            await _movementRepository.Add(Movement);

            await _currentAccountRepository.Update(Movement.CurrentAccount);

            await OnGet();

            return(Page());
        }
        public async Task ExecuteAsync()
        {
            var accounts = await _currentAccountRepository.GetAllCalculateInterest();

            foreach (var account in accounts)
            {
                var movement = new Movement();
                movement.CurrentAccount   = account;
                movement.CurrentAccountId = account.Id;
                movement.CalculateInterest();
                await _movementRepository.Add(movement);

                await _currentAccountRepository.Update(movement.CurrentAccount);
            }
        }