private async void GetInvoices()
        {
            if (!string.IsNullOrWhiteSpace(SearchTerm))
            {
                MessageToDisplay = "Searching...";
                IsBusy           = true;
                ButtonEnabled    = false;
                IsLoading        = true;
                GetInvoicesCommand.RaiseCanExecuteChanged();
                var proxy = _serviceFactory.CreateClient <IInvoiceService>();

                using (proxy)
                {
                    var   invoices = proxy.FindInvoicesByCompanyAsync((Company)CurrentCompany, SearchTerm);
                    await invoices;
                    // FoundItems = new ObservableCollection<Invoice>(orders.Result);

                    if (invoices.Result.Count > 0)
                    {
                        foreach (var invoice in invoices.Result)
                        {
                            FoundItems.Add(Map(invoice));
                        }

                        SelectedItem      = FoundItems[0];
                        SelectedItemIndex = 0;
                    }
                }

                MessageToDisplay = FoundItems.Count.ToString() + " invoice(s) found";
                ButtonEnabled    = true;
                GetInvoicesCommand.RaiseCanExecuteChanged();
                //RaisePropertyChanged(nameof(FoundSome));
                //RaisePropertyChanged(nameof(FoundSomeNo));
            }
            else
            {
                MessageToDisplay = "You must enter a search term in order to find an invoice";
            }
            IsLoading = false;
            IsBusy    = false;
        }
Esempio n. 2
0
        private async void GetInvoices()
        {
            if (!string.IsNullOrWhiteSpace(SearchTerm))
            {
                MessageToDisplay = "Searching...";
                IsBusy           = true;
                ButtonEnabled    = false;
                IsLoading        = true;
                GetInvoicesCommand.RaiseCanExecuteChanged();
                var order_service = _serviceFactory.CreateClient <IInvoiceService>();

                using (order_service)
                {
                    try
                    {
                        var   orders = order_service.FindInvoicesByCompanyAsync((Company)CurrentCompany, SearchTerm);
                        await orders;
                        Invoices = new ObservableCollection <Invoice>(orders.Result);
                    }
                    catch (Exception ex)
                    {
                        MessageToDisplay = ex.Message;
                        return;
                    }
                }

                MessageToDisplay = Invoices.Count.ToString() + " invoice(s) found";
                ButtonEnabled    = true;
                GetInvoicesCommand.RaiseCanExecuteChanged();
                RaisePropertyChanged(nameof(FoundSome));
                RaisePropertyChanged(nameof(FoundSomeNo));
            }
            else
            {
                MessageToDisplay = "You must enter a search term in order to find an invoice";
            }
            IsLoading = false;
            IsBusy    = false;
        }