// PUT api/values/5 public void Put(Lado_Fuerza f) { //Update MySqlConnection conn = new MySqlConnection(connectionString); try { conn.Open(); MySqlCommand cmd = conn.CreateCommand(); string sql = "update lado_fuerza " + "set nombre=@nombre, " + "lado_fuerza.sable=@sable " + "where id=@id;"; cmd.CommandText = sql; cmd.Parameters.AddWithValue("@nombre", f.nombre); cmd.Parameters.AddWithValue("@sable", f.sable); cmd.Parameters.AddWithValue("@id", f.id); cmd.ExecuteNonQuery(); conn.Close(); } catch (MySqlException e) { e.ToString(); conn.Close(); } }
// POST api/values public void Post(Lado_Fuerza f) { //create MySqlConnection conn = new MySqlConnection(connectionString); try { conn.Open(); MySqlCommand cmd = conn.CreateCommand(); string sql = "insert into lado_fuerza values(@id,@nombre,@sable)"; cmd.CommandText = sql; cmd.Parameters.AddWithValue("@id", f.id); cmd.Parameters.AddWithValue("@nombre", f.nombre); cmd.Parameters.AddWithValue("@sable", f.sable); cmd.ExecuteNonQuery(); conn.Close(); } catch (MySqlException e) { e.ToString(); conn.Close(); } }