title: Using ChartJs with MVC 5 Razor
body: <p>I would like to help, I'm trying to display the data of my query in a chart utlizando the ChartJs. How can I return the data in JSON?</p>
  
  <p>FaturamentoIvel.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace BiDAL.Entity.Graficos
  {
      public class FaturamentoIvel
      {
          public string Operacao { get; set; }
          public string AnoMes { get; set; }
          public float ValorNF { get; set; }
          public bool TradeMarketing { get; set; }
      }
  }
  </code></pre>
  
  <p>FaturamentoIvelDAL.cs</p>
  
  <pre><code>using BiDAL.Entity.Graficos;
  using System;
  using System.Collections.Generic;
  using System.Data;
  using System.Data.SqlClient;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace BiDAL.Persistence
  {
      public class FaturamentoIvelDAL : Conexao
      {
          public List&lt;FaturamentoIvel&gt; FindAllFaturamentoIvel()
          {
              try
              {
                  OpenConnection();
                  Cmd = new SqlCommand("SELECT Operacao, AnoMes, TradeMarketing, SUM(ValorNF) AS ValorTotal FROM dbo.FatoFaturamentoIVEL WHERE TradeMarketing = 0 GROUP BY Operacao, AnoMes, TradeMarketing ORDER BY SUM(ValorNF) DESC", Con);
  
                  Dr = Cmd.ExecuteReader();
                  List&lt;FaturamentoIvel&gt; lista = new List&lt;FaturamentoIvel&gt;();
  
                  while (Dr.Read())
                  {
                      FaturamentoIvel ft = new FaturamentoIvel();
                      ft.Operacao = Convert.ToString(Dr["Operacao"]);
                      ft.AnoMes = Convert.ToString(Dr["AnoMes"]);
                      ft.ValorNF = Convert.ToSingle(Dr["ValorNF"]);
  
                      lista.Add(ft);
                  }
                  return lista;
              }
              catch (Exception ex)
              {
                  throw new Exception("Erro ao listar Faturamento: " + ex.Message);
              }
          }
  
  
      }
  }
  </code></pre>
  
  <p>My Controller AdminController</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  
  namespace BiFrontEnd.Controllers
  {
      public class AdminController : Controller
      {
          // GET: Home
          public ActionResult Home()
          {
              return View();
          }
  
  
      }
  }
  </code></pre>
  
  <p>My view </p>
  
  <pre><code>@{
      ViewBag.Title = "Home";
      Layout = "~/Views/Template/_Layout.cshtml";
  }
  
  &lt;label&gt;Gráfico Mês Atual&lt;/label&gt;
  &lt;select id="ddlOperacao"&gt;
      &lt;option&gt;Venda&lt;/option&gt;
      &lt;option&gt;Troca&lt;/option&gt;
      &lt;option&gt;Bonificação&lt;/option&gt;
      &lt;option&gt;Outras&lt;/option&gt;
  &lt;/select&gt;
  &lt;button id="btnGerarGraficoMesAtual"&gt;Exibir&lt;/button&gt;
  </code></pre>