public static PartyProfileDTO GetPartyProfileDTO(PartyProfile party) { PartyProfileDTO dto = new PartyProfileDTO { ID = party.ID, Votes = party.Votes, Seats = party.Seats, Party = GetPartyDTO(party.Party) }; return(dto); }
public static PartyProfile GetPartyProfileFromDTO(PartyProfileDTO dto) { PartyProfile party = new PartyProfile { ID = dto.ID, Votes = dto.Votes, Seats = dto.Seats, Party = GetPartyFromDTO(dto.Party) }; return(party); }
public void CreatePartyProfile(int id, PartyProfileDTO partyProfile) { try { using (connection = DataConnection.GetConnection()) { connection.Open(); using (MySqlCommand command = new MySqlCommand("INSERT INTO PartyProfile(PartyID, ElectionID, Votes, Seats) VALUES (@PartyID, @ElectionID, @Votes, @Seats)", connection)) { command.Parameters.AddWithValue("@ElectionID", id); command.Parameters.AddWithValue("@PartyID", partyProfile.Party.ID); command.Parameters.AddWithValue("@Votes", partyProfile.Votes); command.Parameters.AddWithValue("@Seats", partyProfile.Seats); command.ExecuteNonQuery(); } } } catch (MySqlException) { throw new CreatingPartyProfileFailedException("Het maken van een profiel voor de gegeven partij is mislukt."); } }
public void Save(int id, PartyProfileDTO partyProfile) { try { using (connection = DataConnection.GetConnection()) { connection.Open(); using (MySqlCommand command = new MySqlCommand("UPDATE PartyProfile SET Votes=@Votes, Seats=@Seats WHERE ElectionID=@ElectionID AND PartyID=@PartyID", connection)) { command.Parameters.AddWithValue("@ElectionID", id); command.Parameters.AddWithValue("@PartyID", partyProfile.Party.ID); command.Parameters.AddWithValue("@Votes", partyProfile.Votes); command.Parameters.AddWithValue("@Seats", partyProfile.Seats); command.ExecuteNonQuery(); } } } catch (MySqlException) { throw new UpdatingPartyProfileFailedException("We konden de door u verzochte partij profiel niet vinden."); } }
public void Save(int id, PartyProfileDTO partyProfile) { Context.Save(id, partyProfile); }
public void CreatePartyProfile(int id, PartyProfileDTO partyProfile) { Context.CreatePartyProfile(id, partyProfile); }