private void SearchItemsForTagControl(string inputText) { if (string.IsNullOrEmpty(inputText)) { return; } var acccountsFromSearch = SecurityRepository.Accounts.Where(a => a.UserName.Contains(inputText)).ToList(); var accountsWithFilter = acccountsFromSearch.Except(CollectionFromTagControl.Where(i => i.IsEditing == false).Select(i => i.InnerItem as Account), new AccountEqualityComparer()); SearchedItems = new ObservableCollection <Account>(accountsWithFilter); }
private void RaiseCCme() { var userId = _authContext.CurrentUserId; var account = SecurityRepository.Accounts.Where(a => a.AccountId == int.Parse(userId)).SingleOrDefault(); if (account != null) { var accInResultCollection = CollectionFromTagControl.SingleOrDefault( i => (i.InnerItem as Account).AccountId == account.AccountId); if (accInResultCollection == null) { CollectionFromTagControl.Add(new TagControlItemViewModel(account)); } var view = CollectionViewSource.GetDefaultView(CollectionFromTagControl); view.SortDescriptions.Add(new SortDescription("IsEditing", ListSortDirection.Ascending)); view.Refresh(); } }
private void CollectionInits() { AllAvailableCaseTemplates = _customerRepository.CaseTemplates.Where(x => x.IsActive).ExpandAll().OrderBy(x => x.Name).ToList(); AssignedUserList = SecurityRepository.Accounts .Where( x => (x.RegisterType == (int)RegisterType.Administrator || x.RegisterType == (int)RegisterType.SiteAdministrator) && x.AccountState == (int)AccountState.Approved) .OrderBy(x => x.UserName) .ToList(); if (!string.IsNullOrEmpty(InnerItem.AgentId) && !string.IsNullOrEmpty(InnerItem.AgentName)) { var accID = InnerItem.AgentId; var acc = AssignedUserList.SingleOrDefault(a => a.MemberId == accID); if (acc != null) { SelectedAssignedUser = acc; } } else { if (_caseAction == CaseActionState.New) { var authorId = _authContext.CurrentUserId; var acc = AssignedUserList.SingleOrDefault(a => a.MemberId == authorId); if (acc != null) { SelectedAssignedUser = acc; } } } if (InnerItem.CaseCc.Count > 0) { CollectionFromTagControl.Clear(); foreach (var ccc in InnerItem.CaseCc) { int accId = int.Parse(ccc.AccountId); var account = SecurityRepository.Accounts.Where(a => a.AccountId == accId).SingleOrDefault(); if (account != null) { CollectionFromTagControl.Add(new TagControlItemViewModel(account) { IsEditing = false }); } } } CollectionFromTagControl.Add(new TagControlItemViewModel(new Account()) { IsEditing = true }); CollectionFromTagControl.CollectionChanged += (s, e) => { _parentViewModel.IsModified = true; }; CaseLabelList = new ObservableCollection <Label>(_innerCase.Labels); foreach (var label in CaseLabelList) { CaseLabelListFromTagControl.Add(new TagControlItemViewModel(label) { IsEditing = false }); } CaseLabelListFromTagControl.Add(new TagControlItemViewModel(new Label()) { IsEditing = true }); CaseLabelListFromTagControl.CollectionChanged += (s, e) => { _parentViewModel.IsModified = true; CaseLabelList = new ObservableCollection <Label>(CaseLabelListFromTagControl.Where(i => i.IsEditing == false).Select(i => i.InnerItem as Label).ToList <Label>()); }; }