I need to return the result of the procedure, I put a fixed value just to perform my tests but it will have a typed input, in datepick. But I can not create the list for the columns.
Here is the snippet of code:
public string dtaTotal(string dtaini, string dtafinal)
{
List<string> dtatot = new List<string>();
var result = "'" + dtaini + "'" + "," + "'" + dtafinal + "'";
return result;
}
private List<Campanha> BuscaCampanhas()
{
using (SqlCommand command = new SqlCommand("exec pr_DashBrokerCampanhas '01-09-2018', '10-09-2018'", DBConnection))
{
DBConnection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
List<Campanha> _listCampanhas = new List<Campanha>();
while (reader.Read())
{
_listCampanhas.Add(
new Campanha
{
DescCampanha = reader["DescCampanha"].ToString(),
Total = reader["Total"].ToString(),
Columns = dtaTotal()
}
);
}
DBConnection.Close();
return _listCampanhas;
}
}
}
Campaign Class:
public class Campanha
{
public string DescCampanha { get; set; }
public string Total { get; set; }
public List<string> Columns { get; set; }
}
public class Dashboard
{
public List<Envio> Envios { get; set; }
public List<Broker> Brokers { get; set; }
public List<Campanha> Campanhas { get; set; }
}
Index controller:
var DashboardContent = new Dashboard();
DashboardContent.Envios = BuscaTodosEnvios();
DashboardContent.Brokers = BuscaBrokers();
DashboardContent.Campanhas = BuscaCampanhas();
return View(DashboardContent);