public void CreateCoalition(CoalitionDTO coalition) { try { using (connection = DataConnection.GetConnection()) { connection.Open(); using (MySqlCommand command = new MySqlCommand("INSERT INTO Coalition(ElectionID, PrimeMinister) VALUES (@ElectionID, @PrimeMinister)", connection)) { command.Parameters.AddWithValue("@ElectionID", coalition.election.ID); command.Parameters.AddWithValue("@PrimeMinister", coalition.PrimeMinister); command.ExecuteNonQuery(); } } } catch (MySqlException) { throw new CreatingElectionFailedException("Coalitie maken mislukt."); } }
public void CreateCoalition(CoalitionDTO coalition) { Context.CreateCoalition(coalition); }