Exemplo n.º 1
0
        public DeEatingGuide Save(DeEatingGuide obj)
        {
            if (GetByID(obj.ID, obj.LangCode) == null)
            {
                using (MySqlConnection conn = GetConnection())
                {
                    conn.Open();
                    var          script = $"INSERT INTO `eating_guide` (`ID`, `EatingGuideContent`, `EatingGuideTitle`, `LangCode`, `UpdateDateTime`) VALUES ({obj.ID}, '{obj.EatingGuideContent}', '{obj.EatingGuideTitle}', '{obj.LangCode}', '{obj.UpdateDateTime.ToString("yyyy-MM-dd hh:mm:ss")}');";
                    MySqlCommand cmd    = new MySqlCommand(script, conn);

                    cmd.ExecuteNonQuery();
                }
            }
            else
            {
                using (MySqlConnection conn = GetConnection())
                {
                    conn.Open();
                    var          script = $"UPDATE `eating_guide` SET `EatingGuideTitle` = '{obj.EatingGuideTitle}', `EatingGuideContent` = '{obj.EatingGuideContent}', `UpdateDateTime` = '{obj.UpdateDateTime.ToString("yyyy-MM-dd HH:mm:ss")}' WHERE `ID` = '{obj.ID}' AND `LangCode` = '{obj.LangCode}';";
                    MySqlCommand cmd    = new MySqlCommand(script, conn);

                    cmd.ExecuteNonQuery();
                }
            }
            return(obj);
        }
Exemplo n.º 2
0
 public static DeEatingGuide Save(DeEatingGuide obj)
 {
     return(new DlEatingGuide().Save(obj));
 }