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)); } }
public static DeAppLanguage Save(DeAppLanguage obj) { return(new DlAppLanguage().Save(obj)); }