In my controller i have this:
private void FetchData()
{
//Reinicia a varíavel addresses se já conter algo
if (addresses.Count > 0)
{
addresses.Clear();
}
try
{
con.Open();
com.Connection = con;
com.CommandText = "SELECT [ID], [SYSTEM_NAME], [SYSTEM_STATUS], [SYSTEM_SHORTMSG] FROM [CORE_SYS_STATUS]";
dr = com.ExecuteReader();
while (dr.Read())
{
//Lê os dados da base de dados
addresses.Add(new GestaoAlertas()
{
ID = (int)dr["ID"]
,
SYSTEM_NAME = dr["SYSTEM_NAME"].ToString()
,
SYSTEM_STATUS = dr["SYSTEM_STATUS"].ToString()
,
SYSTEM_SHORTMSG = dr["SYSTEM_SHORTMSG"].ToString()
});
}
con.Close();
}
//Mostra o erro se houver um
catch (Exception ex)
{
throw ex;
}
}
And then i put it in my view:
public IActionResult Index()
{
FetchData();
return View(addresses);
}
I was wondering how do i put more data (different table) into the Index view, i tried doing a addresses2 but it doesn't make sense because I can't put it on the "return View()".