Пример #1
0
        //Normal Search method has been made resuable
        public static async void AccountTypeSearch(CustomSearchControl SearchControl)
        {
            var client             = Helper.getServiceClient();
            AccountTypeQuery query = new AccountTypeQuery();

            if (SearchControl.OptionOne.IsChecked == true)
            {
                query = new AccountTypeQuery()
                {
                    AccountType = int.Parse(SearchControl.SearchTextBox.Text)
                };
            }

            SearchControl.Search = AccountTypeSearch;
            int pagesize     = SearchControl.PageSize;
            int pagePosition = SearchControl.PagePosition;
            var response     = await client.QueryAccountTypeAsync(query, pagesize, pagePosition);

            if (response == null)
            {
                MessageBox.Show("Service isn't responding, please try again later", "Message", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            SearchControl.ResultCount = response.TotalResultCount;
            var servicelist  = response.Result.ToList <FIN_AccountType>();
            var AccountTypes = new ObservableCollection <FIN_AccountType>(servicelist);

            SearchControl.ResultsGrid.ItemsSource = AccountTypes;
        }
Пример #2
0
        public static async void Search(CustomSearchControl SearchControl)
        {
            var client = Helper.getServiceClient();
            AccountTypeQuery query = new AccountTypeQuery(); //by default we have an empty query
             if(SearchControl.OptionOne.IsChecked==true)          
               query = new AccountTypeQuery() { AccountType = int.Parse(SearchControl.SearchTextBox.Text) };
            
            
            //The search control needs to know the method it has to use inorder to search. So we pass a method
            SearchControl.Search = Search;
            int pagesize = SearchControl.PageSize;
            int pagePosition = SearchControl.PagePosition;
            var response = await client.QueryAccountTypeAsync(query, pagesize, pagePosition);

          //  var response = client.ReadAllAccountType(pagesize, pagePosition);

            //No response; exit
            if (response == null)
            {
                MessageBox.Show("Service isn't responding, please try again later", "Message", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            SearchControl.ResultCount = response.TotalResultCount;
            //Fill the datagrid with the results         
            SearchControl.ResultsGrid.ItemsSource = new ObservableCollection<FIN_AccountType>(response.Result.ToList<FIN_AccountType>()); ;         
        }