public DeFoodGroup Save(DeFoodGroup obj) { if (GetByID(obj.ID) == null) { using (MySqlConnection conn = GetConnection()) { conn.Open(); var script = $"INSERT INTO `food_group` (`ID`, `FoodGroupDescription`, `LangCode`) VALUES ({obj.ID}, '{obj.FoodGroupDescription}', '{obj.LangCode}');"; MySqlCommand cmd = new MySqlCommand(script, conn); cmd.ExecuteNonQuery(); } } else { using (MySqlConnection conn = GetConnection()) { conn.Open(); var script = $"UPDATE `food_group` SET `FoodGroupDescription` = '{obj.FoodGroupDescription}' WHERE `ID` = {obj.ID};"; MySqlCommand cmd = new MySqlCommand(script, conn); cmd.ExecuteNonQuery(); } } return(obj); }
public static DeFoodGroup Save(DeFoodGroup obj) { return(new DlFoodGroup().Save(obj)); }