Exemplo n.º 1
0
        public ActionResult <int> UpdateTier(long id, TierInput tier)
        {
            SQLConnectionTier t = new("server=localhost;port=3306;database=ZooDatenbank;user=root;password=root");

            if (t.UpdateTier(id, tier) == 1)
            {
                return(1);
            }
            else
            {
                return(NotFound());
            }
        }
Exemplo n.º 2
0
        public ActionResult <TierInput> CreateTier(TierInput tier)
        {
            SQLConnectionTier t = new("server=localhost;port=3306;database=ZooDatenbank;user=root;password=root");

            if (t.CreateTier(tier) >= 1)
            {
                return(tier);
            }
            else
            {
                throw new Exception("didn't work");
            }
        }
Exemplo n.º 3
0
 // UPDATE exisiting tier
 public int UpdateTier(long id, TierInput tier)
 {
     using (MySqlConnection conn = GetConnection())
     {
         conn.Open();
         int help = 0;
         if (tier.Vegetarier == true)
         {
             help = 1;
         }
         MySqlCommand cmd = new MySqlCommand("UPDATE tier SET ZooID = '" + tier.ZooID + "', Tierart = '" + tier.Tierart + "', Name = '" + tier.Name + "', Vegetarier = '" + help + "' WHERE ID = '" + id + "';", conn);
         return(cmd.ExecuteNonQuery());
     }
 }
Exemplo n.º 4
0
 // CREATE new tier
 public int CreateTier(TierInput tier)
 {
     using (MySqlConnection conn = GetConnection())
     {
         conn.Open();
         int help = 0;
         if (tier.Vegetarier == true)
         {
             help = 1;
         }
         MySqlCommand cmd = new MySqlCommand("INSERT INTO tier (ZooID, Tierart, Name, Vegetarier) VALUES ('" + tier.ZooID + "', '" + tier.Tierart + "', '" + tier.Name + "', '" + help + "')", conn);
         return(cmd.ExecuteNonQuery());
     }
 }