public async Task <IActionResult> Get(HttpMonitorId httpMonitorId) { var httpMonitor = await _service.GetHttpMonitorByIdAsync(httpMonitorId); if (httpMonitor != null) { return(Ok(httpMonitor)); } return(NotFound()); }
public static async Task <HttpResponseMessage> GetByIdAsync( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "httpmonitors/{httpMonitorId}")] HttpRequestMessage req, string httpMonitorId, TraceWriter log, [Inject] IHttpMonitorService service, [Inject] JsonMediaTypeFormatter formatter) { if (!HttpMonitorId.TryParse(httpMonitorId, out var id)) { return(req.CreateResponse(HttpStatusCode.NotFound)); } var httpMonitor = await service.GetHttpMonitorByIdAsync(id); if (httpMonitor != null) { return(req.CreateResponse(HttpStatusCode.OK, httpMonitor, formatter)); } return(req.CreateResponse(HttpStatusCode.NotFound)); }