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