public ArticleViewModel GetProduct(int id) { ArticleViewModel arti = new ArticleViewModel(); using (MySqlConnection conn = GetConnection()) { conn.Open(); MySqlCommand cmd = new MySqlCommand("SELECT * FROM producto where id = " + id, conn); using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { int Id = reader.GetInt32("id"); string Nombre = reader.GetString("nombre"); double Precio = reader.GetDouble("precio"); string Imagen = reader.GetString("imagen"); int Cantidad = reader.GetInt32("cantidad"); arti = new ArticleViewModel(Id, Nombre, Cantidad, Precio, Imagen); } } } return(arti); }
public BillDetailViewModel(int cantidad, ArticleViewModel producto) { Cantidad = cantidad; Producto = producto; }