public AssociatePickList(Func <AssociateCollection> associateCollectionFactory, Func <IAssociate> associateFactory) { _associateFactory = associateFactory; _associateCollectionFactory = associateCollectionFactory; Associates = _associateCollectionFactory.Invoke(); Associates.Clear(); _selectedAssociate = null; }
private void LoadAssociates(int salesdivisionid) { FullyObservableCollection <UserModel> associatess = DatabaseQueries.GetUsers(); FilterListItem fi; Associates?.Clear(); var q = from associat in associatess where !associat.Deleted && associat.BusinessUnits.Split(',').ToList().Contains(salesdivisionid.ToString()) select associat; if (CurrentUser.ShowOthers) { foreach (UserModel ag in q) { fi = new FilterListItem(); { fi.ID = ag.ID; fi.Name = ag.Name; fi.IsSelected = false; fi.VisibleState = Visibility.Visible; fi.PropertyChanged += FlAssociates_PropertyChanged; Associates.Add(fi); } } foreach (FilterListItem fil in associates) { if (fil.ID == CurrentUser.ID) { fil.IsSelected = true; } } } else { fi = new FilterListItem(); { fi.ID = CurrentUser.ID; fi.Name = CurrentUser.Name; fi.IsSelected = true; fi.VisibleState = Visibility.Visible; fi.PropertyChanged += FlAssociates_PropertyChanged; Associates.Add(fi); } } }