public void DeleteBorasz(Borasz model) { using (MySqlConnection con = new MySqlConnection(conStr)) { con.Open(); string sql = "DELETE FROM Borasz WHERE Id = @Id;"; using (MySqlCommand cmd = new MySqlCommand(sql, con)) { cmd.Parameters.AddWithValue("@Id", model.Id); cmd.ExecuteNonQuery(); } } }
public Borasz InsertBorasz(Borasz model) { using (MySqlConnection con = new MySqlConnection(conStr)) { con.Open(); string sql = "INSERT INTO Borasz(Nev, Email, Telefon) VALUES(@Nev, @Email, @Telefon); "; using (MySqlCommand cmd = new MySqlCommand(sql, con)) { cmd.Parameters.AddWithValue("@Nev", model.Nev); cmd.Parameters.AddWithValue("@Email", model.Email); cmd.Parameters.AddWithValue("@Telefon", model.Telefon); cmd.ExecuteNonQuery(); int id = (int)cmd.LastInsertedId; return(GetBorasz(id)); } } }
public Borasz UpdateBorasz(Borasz model) { using (MySqlConnection con = new MySqlConnection(conStr)) { con.Open(); string sql = "UPDATE Borasz SET Nev = @Nev, Email = @Email, Telefon = @Telefon WHERE Id = @Id;"; using (MySqlCommand cmd = new MySqlCommand(sql, con)) { cmd.Parameters.AddWithValue("@Nev", model.Nev); cmd.Parameters.AddWithValue("@Email", model.Email); cmd.Parameters.AddWithValue("@Telefon", model.Telefon); cmd.Parameters.AddWithValue("@Id", model.Id); cmd.ExecuteNonQuery(); return(GetBorasz(model.Id)); } } }