public async Task <ActionResult> GetProductByIdAsync([FromRoute] int id) { _logger.LogInformation("Calling GetProductById on the repository"); var error = new ErrorResponse { RequestId = HttpContext?.TraceIdentifier ?? Guid.NewGuid().ToString() }; try { if (ModelState.IsValid) { var result = await _evalRepository.GetProductByIdAsync(id); if (result != null) { return(new JsonResult(result)); } else { return(NotFound()); } } } catch (Exception e) { error.Errors.Add(ErrorModel.FromApiErrorCode(ApiErrorCode.FailToGetData)); _logger.LogError($"Fail to retrieve prescribing information {e.Message}", e); return(StatusCode((int)HttpStatusCode.InternalServerError, error)); } return(BadRequest()); }