public CategoryCell AddCategory(ref CategoryCell category) { lock (locker) { using (MySqlCommand commandSQL = new MySqlCommand(insertCategory, connection)) { commandSQL.Parameters.AddWithValue("@category_name", category.category_name); commandSQL.Parameters.AddWithValue("@category_position", category.category_position); commandSQL.Parameters.AddWithValue("@created_at", category.created_at); commandSQL.ExecuteNonQuery(); category.category_id = (int)commandSQL.LastInsertedId; commandSQL.Dispose(); } } return(category); }
private CategoryCell SelectCategory(MySqlCommand commandSQL) { lock (locker) { using (MySqlDataReader readerMassive = commandSQL.ExecuteReader()) { while (readerMassive.Read()) { CategoryCell category = new CategoryCell(); category.category_id = readerMassive.GetInt32("category_id"); category.category_name = readerMassive.GetString("category_name"); category.category_position = readerMassive.GetInt16("category_position"); category.created_at = readerMassive.GetString("created_at"); commandSQL.Dispose(); return(category); } return(null); } } }
private List <CategoryCell> SelectCategories(MySqlCommand commandSQL) { List <CategoryCell> categories = new List <CategoryCell>(); lock (locker) { using (MySqlDataReader readerMassive = commandSQL.ExecuteReader()) { while (readerMassive.Read()) { CategoryCell category = new CategoryCell(); category.category_id = readerMassive.GetInt32("category_id"); category.category_name = readerMassive.GetString("category_name"); category.category_position = readerMassive.GetInt16("category_position"); category.created_at = readerMassive.GetString("created_at"); categories.Add(category); } commandSQL.Dispose(); } } return(categories); }