public async Task <OpportunityViewModel> GetItemByIdAsync(string id, string requestId = "") { _logger.LogInformation($"RequestId: {requestId} - GetItemByIdAsync called."); Guard.Against.NullOrEmpty(id, nameof(id), requestId); try { var thisOpportunity = new Opportunity(); if (id == "testdata") // To get test data instead of going to back end { thisOpportunity = TestData(); thisOpportunity.Id = id; } else { thisOpportunity = await _opportunityRepository.GetItemByIdAsync(id, requestId); } if (thisOpportunity.Id != id) { _logger.LogWarning($"RequestId: {requestId} - GetItemByIdAsync no items found"); throw new NoItemsFound($"RequestId: {requestId} - Method name: GetItemByIdAsync - No Items Found"); } return(await _opportunityHelpers.ToOpportunityViewModelAsync(thisOpportunity, requestId)); } catch (Exception ex) { _logger.LogError($"RequestId: {requestId} - GetItemByIdAsync Service Exception: {ex}"); throw new ResponseException($"RequestId: {requestId} - GetItemByIdAsync Service Exception: {ex}"); } }