예제 #1
0
        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);
        }
예제 #2
0
 public static DeFoodGroup Save(DeFoodGroup obj)
 {
     return(new DlFoodGroup().Save(obj));
 }