// UPDATE exisiting zoo
 public int UpdateZoo(long id, ZooInput zoo)
 {
     using (MySqlConnection conn = GetConnection())
     {
         conn.Open();
         MySqlCommand cmd = new MySqlCommand("UPDATE zoo SET Ort = '" + zoo.Ort + "', Name = '" + zoo.Name + "' WHERE ID = '" + id + "';", conn);
         return(cmd.ExecuteNonQuery());
     }
 }
 // CREATE new zoo
 public int CreateZoo(ZooInput zoo)
 {
     using (MySqlConnection conn = GetConnection())
     {
         conn.Open();
         MySqlCommand cmd = new MySqlCommand("INSERT INTO zoo (Ort, Name) VALUES ('" + zoo.Ort + "', '" + zoo.Name + "')", conn);
         return(cmd.ExecuteNonQuery());
     }
 }
示例#3
0
        public ActionResult <int> UpdateZoo(long id, ZooInput zoo)
        {
            SQLConnectionZoo t = new("server=localhost;port=3306;database=ZooDatenbank;user=root;password=root");

            if (t.UpdateZoo(id, zoo) == 1)
            {
                return(1);
            }
            else
            {
                return(NotFound());
            }
        }
示例#4
0
        public ActionResult <ZooInput> CreateZoo(ZooInput zoo)
        {
            SQLConnectionZoo t = new("server=localhost;port=3306;database=ZooDatenbank;user=root;password=root");

            if (t.CreateZoo(zoo) >= 1)
            {
                return(zoo);
            }
            else
            {
                throw new Exception("didn't work");
            }
        }