public async Task <IActionResult> getCustomers([FromRoute] string document) { try { ExternalResponse httpResponse = await insuranceManagementService.GetCustomers(); if (httpResponse.IsSuccessStatusCode) { CustomerResponses customers = JsonConvert.DeserializeObject <CustomerResponses>(httpResponse.Body); return(await CreateResponseWithCode(customers.Customers, (HttpStatusCode)httpResponse.StatusCode)); } else { var result = httpResponse.Body; var obj = JsonConvert.DeserializeObject <dynamic>(result); return(await CreateResponseWithCode(obj, (HttpStatusCode)httpResponse.StatusCode)); } } catch (Exception ex) { return(await CreateErrorMessageForException(ex)); } }
public ExternalResponse GetDefaultCustomersFormatted() { CustomerResponses response = new CustomerResponses(); response.Customers = new List <Customer>(); response.Customers.Add( new Customer { document = "98632674", name = "Mauricio Cadavid" } ); response.Customers.Add( new Customer { document = "8288221", name = "Hernan Cadavid" } ); response.Customers.Add( new Customer { document = "43160724", name = "Maribel Gonzalez" } ); return(new ExternalResponse { IsSuccessStatusCode = true, StatusCode = 200, Body = JsonConvert.SerializeObject(response) }); }