public Varietal GetVarietalById(int id) { using var connection = GetConnection(); connection.Open(); var command = new MySqlCommand($"select varietal_id, category_id, varietal_name, varietal_description, varietal_image from varietal where varietal_id = {id}", connection); using var reader = command.ExecuteReader(); if (!reader.Read()) { return(null); } var varietalId = Convert.ToInt32(reader["varietal_id"]); var categoryId = Convert.ToInt32(reader["category_id"]); var varietalName = reader["varietal_name"].ToString(); var varietalDescription = reader["varietal_description"].ToString(); var varietalImage = reader["varietal_image"].ToString(); var varietal = new Varietal() { VarietalId = varietalId, CategoryId = categoryId, VarietalName = varietalName, VarietalDescription = varietalDescription, VarietalImage = varietalImage }; return(varietal); }
public List <Varietal> GetVarietals() { var result = new List <Varietal>(); using var connection = GetConnection(); connection.Open(); var command = new MySqlCommand( "select varietal_id, category_id, varietal_name, varietal_description, varietal_image from varietal", connection); using var reader = command.ExecuteReader(); while (reader.Read()) { var varietalId = Convert.ToInt32(reader["varietal_id"]); var categoryId = Convert.ToInt32(reader["category_id"]); var varietalName = reader["varietal_name"].ToString(); var varietalDescription = reader["varietal_description"].ToString(); var varietalImage = reader["varietal_image"].ToString(); var varietal = new Varietal() { VarietalId = varietalId, CategoryId = categoryId, VarietalName = varietalName, VarietalDescription = varietalDescription, VarietalImage = varietalImage }; result.Add(varietal); } return(result); }
public List <Varietal> GetVarietalsOfCategory(int categoryId) { var result = new List <Varietal>(); using var connection = GetConnection(); connection.Open(); var command = new MySqlCommand( $"select varietal_id, varietal_name from varietal where category_id = {categoryId}", connection); using var reader = command.ExecuteReader(); while (reader.Read()) { var varietalId = Convert.ToInt32(reader["varietal_id"]); var varietalName = reader["varietal_name"].ToString(); var varietal = new Varietal { VarietalId = varietalId, VarietalName = varietalName }; result.Add(varietal); } return(result); }
public void AddToVarietals(Varietal varietal) { base.AddObject("Varietals", varietal); }
public static Varietal CreateVarietal(string ID) { Varietal varietal = new Varietal(); varietal.Id = ID; return varietal; }