1
I need to return the result of the trial, I put a fixed value just to perform my tests but it will have an input typed, in datepick. However I cannot create the list for the columns.
Follow the code excerpt:
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;
}
}
}
Class Campaign:
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);