public async Task DepositAsync_WithAmountMoreThanZero_ReturnTransactionsResult()
        {
            // Arrange
            var depositRequest = new DepositRequest
            {
                AccountIban = "TH123456",
                Amount      = 1000,
            };

            var account = new Account
            {
                AccountId   = Guid.NewGuid(),
                AccountIban = "TH123456",
                Balance     = 1000,
            };

            accountRepository.GetByAccountIbanAsync(Arg.Any <string>()).Returns(Task.FromResult(account));
            accountRepository.UpdateAccountAsync(Arg.Any <Account>()).Returns(Task.FromResult(new Account()));
            depositRepository.AddDepositAsync(Arg.Any <Deposit>()).Returns(Task.FromResult(new Deposit()));

            // Act
            var transactionsResult = await transactionsService.DepositAsync(depositRequest);

            // Assert
            Assert.True(transactionsResult.Success);
            Assert.Equal(1999, transactionsResult.Balance);
        }
        public async Task <TransactionsResult> DepositAsync(DepositRequest depositRequest)
        {
            var transactionsResult = new TransactionsResult
            {
                AccountIban      = depositRequest.AccountIban,
                Amount           = depositRequest.Amount,
                Success          = false,
                ErrorMessage     = string.Empty,
                TransactionsType = "Deposit",
                TransactionsDate = DateTime.UtcNow
            };

            if (depositRequest.Amount <= 0)
            {
                transactionsResult.ErrorMessage = "Deposit amount is incorret";
                return(transactionsResult);
            }

            var account = await accountRepository.GetByAccountIbanAsync(depositRequest.AccountIban);

            if (account == null)
            {
                transactionsResult.ErrorMessage = "Account does not exists";
                return(transactionsResult);
            }

            var amount = (double)depositRequest.Amount;
            var fee    = amount * 0.1 / 100;
            var total  = amount - fee;

            account.Balance += (decimal)total;

            await accountRepository.UpdateAccountAsync(account);

            var deposit = new Deposit
            {
                DepositId = Guid.NewGuid(),
                AccountId = account.AccountId,
                Amount    = depositRequest.Amount,
                Timestamp = DateTime.UtcNow
            };

            await depositRepository.AddDepositAsync(deposit);

            transactionsResult.Balance = account.Balance;
            transactionsResult.Success = true;

            return(transactionsResult);
        }