public Category getValuesAsCategory(CategoryFilter cf) { string text = this.textBoxTitle.Text; List <Participant> participants = new List <Participant>(); foreach (DataGridViewRow row in (IEnumerable)this.dataGridViewParticipants.Rows) { if (row.Cells["FullName"].Value != null && row.Cells["Team"].Value != null) { int id = 0; if (row.Cells["id"].Value != null) { id = Convert.ToInt32(row.Cells["id"].Value.ToString()); } string name = row.Cells["FullName"].Value.ToString(); string team = row.Cells["Team"].Value.ToString(); Participant participant = new Participant(); participant.setName(name); participant.setTeam(team); if (id > 0) { participant.setId(id); } participants.Add(participant); } } return(new Category(text, participants, cf)); }
private int changeParticipants(Team newTeam) { int num = 0; foreach (Category category in this.categories) { category.getParticipants().RemoveAll((Predicate <Participant>)(p => p.getTeam() == newTeam.getName())); } using (List <Participant> .Enumerator enumerator = newTeam.getParticipants().GetEnumerator()) { while (enumerator.MoveNext()) { Participant p = enumerator.Current; foreach (Category category in this.categories) { try { category.getParticipants().First <Participant>((Func <Participant, bool>)(s => s.getId() == p.getId())).setName(p.getName()); if (!category.getParticipants().Contains(p) && category.getFilter().participantMatch(p)) { category.getParticipants().Add(p); ++num; } } catch (Exception ex) { if (!category.getParticipants().Contains(p) && category.getFilter().participantMatch(p)) { p.setTeam(newTeam.getName()); category.getParticipants().Add(p); } ++num; } } } } return(num); }