Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 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.");
     }
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 6
0
 public void CreatePartyProfile(int id, PartyProfileDTO partyProfile)
 {
     Context.CreatePartyProfile(id, partyProfile);
 }