public void ShowDialog() { if (AssignableUsers.Any()) { Users.Clear(); foreach (User u in AssignableUsers.OrderByDescending(u => u.IsMechanic)) { Users.Add(new Tuple <int, string, bool>(u.UserId, u.FullName, AssignedUsers.Where(us => us.UserId == u.UserId).Any())); } FrmOptionPicker = new frmOptionPicker(ParentForm, Users); DialogResult result = FrmOptionPicker.ShowDialog(ParentForm); if (result == DialogResult.OK) { var PickedItems = FrmOptionPicker.ReturnItems; AssignedUsers.Clear(); if (PickedItems.Any(i => i.Item3 == true)) { foreach (var item in PickedItems.Where(i => i.Item3 == true)) { AssignedUsers.Add(new User { UserId = item.Item1, Name = item.Item2 }); } AssignedUserNames = "Przypisani: " + string.Join(", ", PickedItems.Where(t => t.Item3).Select(t => t.Item2).ToList()); } else { AssignedUserNames = "Przypisani: "; } } } }
public void RemoveAssignedUser(int id) { var projectuser = AssignedUsers.Where(m => m.Id == id).FirstOrDefault(); ProjectUserRepository.RemoveAssignedUser(projectuser); InitializeData(); }