public void FetchUserEventsByAttendings(User i_User, ListBox i_ListBoxEventsByMinimumNumberOfParticipants, TextBox i_MinimumNumber, System.Windows.Forms.BindingSource i_BindingSource) { try { if (i_User != null) { ListOfValidEvents.Clear(); i_ListBoxEventsByMinimumNumberOfParticipants.Invoke(new Action(() => { i_ListBoxEventsByMinimumNumberOfParticipants.DataSource = null; i_ListBoxEventsByMinimumNumberOfParticipants.Items.Clear(); })); bool isNumber = checkIfValidInput(i_MinimumNumber.Text); if (isNumber) { int intNumber = int.Parse(i_MinimumNumber.Text); if (intNumber >= 0) { GetValidEvents(intNumber, i_User); NumberOfEventAttenders = ListOfValidEvents.Count; if (NumberOfEventAttenders > 0) { lock (sr_AddToListLock) { i_BindingSource.DataSource = ListOfValidEvents; i_ListBoxEventsByMinimumNumberOfParticipants.Invoke(new Action(() => i_ListBoxEventsByMinimumNumberOfParticipants.DataSource = i_BindingSource)); } } else { MessageBox.Show("There are no events that match!"); } } else { MessageBox.Show("Error! Please enter a positive number only."); } } else { MessageBox.Show("Error! Please enter numbers only."); } } else { throw new Exception("You must be logged in, in order to proceed."); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
public override void GetValidEvents(int i_Number, User i_User) { foreach (Event fbEvent in i_User.Events) { lock (sr_AddToListLock) { if (fbEvent.AttendingUsers.Count >= i_Number) { ListOfValidEvents.Add(fbEvent); } } } }