-1
I’m making a call inside the API to return consumer data, but I would like to know how to return this data to the client in JSON format.
My controller:
[System.Web.Http.HttpGet]   
public async Task<ActionResult> GetConsumidor()
{
  ConsumidorDAO consumidor = new ConsumidorDAO();
  string dadosConsumidor = consumidor.getDados();
  return (dadosConsumidor);
}
I make a query in the database to bring up some data of a consumer such as name, surname, etc.
public string getDados()
{
  OracleCommand lOracleCommand = lOracleConnection.CreateCommand();
  String query;
  string nome = "";
  try
  {
    query = "select nome " +
      "from crd.cliente " +
      "where cpf_cgc = 'xxxxxxx'" +
      "  and empresa_origem = '367' ";
    lOracleCommand.CommandText = query;
    OracleDataReader reader = lOracleCommand.ExecuteReader();
    while (reader.Read())
    {
      nome = reader["nome"].ToString();
    }
  }
  catch (Exception lException)
  {
    _status += lException.Message + "\n";
    lOracleCommand.Connection.Close();
  }
  return nome;
}
The client would be what exactly? for example, you would save the data in a text file?
– Rebeca Nonato
I only return the data in formed JSON with the information
– DonRuan