public async Task <double> GetUserRemainingLimitAsync(int userId, string currencyCode, DateTime transactionDate) { double?currencyTransactionLimitPerMonth = await TransactionsRepository.GetCurrencyTransactionLimitAsync(currencyCode); if (!currencyTransactionLimitPerMonth.HasValue) { throw new InvalidOperationException($"Currency transaction limite not found for currency code {currencyCode}"); } double amountAlreadyExchanged = await TransactionsRepository.GetUserAmountExchangedPerMonthAsync(userId, currencyCode, transactionDate); return(currencyTransactionLimitPerMonth.Value - amountAlreadyExchanged); }