public async Task <ActionResult> Create([FromBody] string personData) { try { Thread.Sleep(1000); var response = await _searchApi.Add("api/v1/search", personData); if (response.Content == null) { _logger.Warn("No contents returned on response."); return(new EmptyResult()); } var result = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { return(Content(response.StatusCode.ToString())); } _logger.Error(string.Format("Error on response: {0}", response.ReasonPhrase)); return(HttpNotFound("An error occured")); } catch (HttpResponseException hrex) { _logger.Error(hrex); return(HttpNotFound(string.Format("An error occured:", hrex.Message))); } }
public IHttpActionResult Get() { try { var list = _searchService.Get(); if (list.Any()) { return(Json(list)); } else { _logger.Warn("No data content received from database."); return(StatusCode(System.Net.HttpStatusCode.NoContent)); } } catch (HttpResponseException hrex) { _logger.Error(hrex); return(StatusCode(System.Net.HttpStatusCode.InternalServerError)); } }