예제 #1
0
 public void Clear()
 {
     if (handles != null)
     {
         handles.Clear();
     }
 }
        private async void ExecuteSearchPublicGroupAsync(string expression)
        {
            if (expression?.Length == 1 && CachedList.Count == 0)
            {
                CachedList = new ObservableCollection <GrupoOferta>(GruposOfertasUsuario);
            }
            GruposOfertasUsuario.Clear();

            if (string.IsNullOrEmpty(expression))
            {
                foreach (var item in CachedList)
                {
                    GruposOfertasUsuario.Add(item);
                }
                CachedList.Clear();
                return;
            }

            var result = await grupoOfertaService.LocalizarGruposOfertaPublicosAsync(expression);

            foreach (var item in result)
            {
                GruposOfertasUsuario.Add(item);
            }
        }
        private async void ExecuteSearchUserAsync(string expression)
        {
            if (expression == null)
            {
                return;
            }

            if (expression?.Length == 1 && CachedList.Count == 0)
            {
                CachedList = new ObservableCollection <ParticipanteLista>(Members);
            }
            Members.Clear();
            editListaCompraDetalheViewModel.Members.Clear();

            if (string.IsNullOrEmpty(expression))
            {
                foreach (var item in CachedList)
                {
                    Members.Add(editListaCompraDetalheViewModel.AdicionarParticipante(item));
                }
                CachedList.Clear();
                return;
            }

            var users = await userService.LocalizarUsuariosPesquisadosAsync(expression);

            if (users != null)
            {
                foreach (var user in users)
                {
                    Members.Add(editListaCompraDetalheViewModel?.AdicionarParticipante(new ParticipanteLista(user.Id)
                    {
                        User = user
                    }));
                }
            }
        }
        private async void ExecuteSearchProductAsync(string expression)
        {
            if (expression == null)
            {
                return;
            }

            if (expression?.Length == 1 && CachedList.Count == 0)
            {
                IsNotSearching = false;
                OnPropertyChanged(nameof(IsNotSearching));
                CachedList = new ObservableCollection <GroupCollection <char, ProdutoListaCompraViewModel> >(ProdutosListaCompra);
            }
            ProdutosListaCompra.Clear();

            if (string.IsNullOrEmpty(expression))
            {
                IsNotSearching = true;
                OnPropertyChanged(nameof(IsNotSearching));
                foreach (var item in CachedList)
                {
                    ProdutosListaCompra.Add(item);
                }
                await listaCompraService.LoadAutoCompleteAsync(TransformGroupedCollectionToModel(ProdutosListaCompra).Select(x => x.Produto?.Id).ToArray());

                CachedList.Clear();
                return;
            }

            var produtos = await listaCompraService.ObterProdutoPorNome(expression);

            if (produtos != null)
            {
                GroupCollection(produtos);
            }
        }