public async Task <ActionResult <IEnumerable <Transaction> > > GetTransactionDetailsByAccountID(int id) { try { IEnumerable <Transaction> result = null; _logger?.LogInformation(string.Format("Start GetTransactionDetailsByAccountID: {0}", id.ToString())); result = await _repo?.GetTransactionDetailsByAccountID(id) ?? null; // Check if return object was null. if (result == null || result?.Count() < 1) { // Return NotFound 404 response if no account detail was found for ID. _logger?.LogWarning(string.Format("Account #{0} transaction details not found!", id.ToString())); return(NotFound(null)); } // Return list of transactions found. _logger?.LogInformation(string.Format("GetTransactionDetailsByAccountID: {0} Succeeded.", id.ToString())); return(Ok(result.OrderByDescending(tr => tr.TimeStamp).ToList())); } catch (Exception WTF) { // Return Internal Server Error 500 on general exception. _logger?.LogError(WTF, "Unexpected Error in GetTransactionDetailsByAccountID!"); return(StatusCode(StatusCodes.Status500InternalServerError)); } }