// UPDATE exisiting gehege public int UpdateGehege(long id, GehegeInput gehege) { using (MySqlConnection conn = GetConnection()) { conn.Open(); MySqlCommand cmd = new MySqlCommand("UPDATE gehege SET Gehegeart = '" + gehege.Gehegeart + "', TierID = '" + gehege.TierID + "', ZooID = '" + gehege.ZooID + "' WHERE ID = '" + id + "';", conn); return(cmd.ExecuteNonQuery()); } }
// CREATE new gehege public int CreateGehege(GehegeInput gehege) { using (MySqlConnection conn = GetConnection()) { conn.Open(); MySqlCommand cmd = new MySqlCommand("INSERT INTO gehege (Gehegeart, TierID, ZooID) VALUES ('" + gehege.Gehegeart + "', '" + gehege.TierID + "', '" + gehege.ZooID + "')", conn); return(cmd.ExecuteNonQuery()); } }
public ActionResult <int> UpdateGehege(long id, GehegeInput gehege) { SQLConnectionGehege t = new("server=localhost;port=3306;database=ZooDatenbank;user=root;password=root"); if (t.UpdateGehege(id, gehege) == 1) { return(1); } else { return(NotFound()); } }
public ActionResult <GehegeInput> CreateGehege(GehegeInput gehege) { SQLConnectionGehege t = new("server=localhost;port=3306;database=ZooDatenbank;user=root;password=root"); if (t.CreateGehege(gehege) >= 1) { return(gehege); } else { throw new Exception("didn't work"); } }