public IActionResult Find(int?marketId) { try { if (!marketId.HasValue) { return(BadRequest("Invalid Input.")); } var result = _marketRepository.Find(marketId); if (result != null) { _logger.LogInformation($"ID : {marketId} has been successfully found."); return(Ok(result)); } else { _logger.LogError("Market ID : {0} was not found.", marketId); return(StatusCode(404, StatusCodes.ReturnStatusObject("Market Not Found."))); } } catch (Exception e) { _logger.LogError("Failed to located Market. Error - {0}", e.Message); return(StatusCode(400, StatusCodes.ReturnStatusObject("Something went wrong."))); } }