I'm doing a web in ASP.NET MVC 5 that shows a list of people, currently only shows the ones that are in that day, but since the bd stores every day I want to create a view that is history style that they put the day that they want to show and that this makes that query in the database but for more that I look for I can not find how to do so that from the view they send a date and this update the view with the results of that day.
I have two models
public class Articulo
{
public string Nombre { get; set; }
public int Id{ get; set; }
public string Comentario { get; set; }
public DateTime Fecha { get; set; }
}
public List<Articulo> RecuperarHistorial(DateTime fecha)
{
Conectar();
List<Articulo> articulos = new List<Articulo>();
fechacomp = fecha.ToString("yyyy-MM-dd");
NpgsqlCommand com = new NpgsqlCommand("select * From registro where fecha = '" + fechacomp + "';", con);
con.Open();
NpgsqlDataReader registros = com.ExecuteReader();
while (registros.Read())
{
Articulo art = new Articulo
{
Nombre = registros["nombre"].ToString(),
Id = int.Parse(registros["id"].ToString()),
Comentario = registros["comentario"].ToString(),
Fecha = DateTime.Parse(registros["fecha"].ToString()),
};
articulos.Add(art);
}
con.Close();
return articulos;
}
and I want to create a view that can send the date to that query but I do not know how to do it but as it is a list it did not work and I am totally lost