public ContactDirectory() { teams = new List<Team>(); contacts = DemoData.GetRandomContacts(5000); var t1 = new Team() { Name = "X Ray", Id = "8888", TeamMembers = new List<Contact>() }; t1.TeamMembers.Add(contacts.Single(m => m.Id == "1111")); t1.TeamMembers.Add(contacts.Single(m => m.Id == "2222")); teams.Add(t1); }
public void UpdateContact(Contact contact) { var found = contacts.SingleOrDefault(m => m.Id == contact.Id); if (found != null) { //contacts.Remove(found); //contacts.Add(contact); int idx = contacts.IndexOf(found); //found = contact; contacts[idx] = contact; teams = new List<Team>(); var t1 = new Team() { Name = "X Ray", Id = "8888", TeamMembers = new List<Contact>() }; t1.TeamMembers.Add(contacts.Single(m => m.Id == "1111")); t1.TeamMembers.Add(contacts.Single(m => m.Id == "2222")); t1.TeamMembers.Add(contacts.Single(m => m.Id == "3333")); teams.Add(t1); } else { contacts.Add(contact); } }