Esempio n. 1
0
        public DeAppLanguage Save(DeAppLanguage obj)
        {
            if (GetByCode(obj.LangCode) == null)
            {
                using (MySqlConnection conn = GetConnection())
                {
                    conn.Open();
                    var          script = $"INSERT INTO `app_languages` (`LangCode`, `LangDescription`) VALUES ('{obj.LangCode}', '{obj.LangDescription}');";
                    MySqlCommand cmd    = new MySqlCommand(script, conn);

                    cmd.ExecuteNonQuery();
                }
            }
            else
            {
                using (MySqlConnection conn = GetConnection())
                {
                    conn.Open();
                    var          script = $"UPDATE `app_languages` SET `LangDescription` = '{obj.LangDescription}' WHERE `LangCode` = '{obj.LangCode}';";
                    MySqlCommand cmd    = new MySqlCommand(script, conn);

                    cmd.ExecuteNonQuery();
                }
            }
            return(obj);
        }
 public async Task <IActionResult> PostLanguage([FromBody] DeAppLanguage obj)
 {
     try
     {
         obj = BlAppLanguage.Save(obj);
         return(Ok("Success"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Esempio n. 3
0
 public static DeAppLanguage Save(DeAppLanguage obj)
 {
     return(new DlAppLanguage().Save(obj));
 }