Exemplo n.º 1
0
 // 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());
     }
 }
Exemplo n.º 2
0
 // 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());
     }
 }
Exemplo n.º 3
0
        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());
            }
        }
Exemplo n.º 4
0
        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");
            }
        }