public void GetSearchResults()
 {
     GetSearchResultsCall api = new GetSearchResultsCall(this.apiContext);
     PriceRangeFilterType pf = new PriceRangeFilterType();
     pf.MinPrice = new AmountType();
     pf.MinPrice.Value = 1.0;
     pf.MinPrice.currencyID = CurrencyCodeType.USD;
     pf.MaxPrice = new AmountType();
     pf.MaxPrice.Value = 999.99;
     pf.MaxPrice.currencyID = CurrencyCodeType.USD;
     api.PriceRangeFilter = pf;
     api.ItemTypeFilter = ItemTypeFilterCodeType.AllItems;
     api.Query = "DVD";
     // Time filter
     System.DateTime calTo = System.DateTime.Now;
     System.DateTime calFrom = calTo.AddDays(-7);
     api.ModTimeFrom = calFrom;
     //api.EndTimeTo = calTo;
     // Pagination
     PaginationType pt = new PaginationType();
     pt.EntriesPerPage = 50; pt.EntriesPerPageSpecified = true;
     pt.PageNumber = 1; pt.PageNumberSpecified = true;
     api.Pagination = pt;
     // Make API call.
     SearchResultItemTypeCollection items = api.GetSearchResults(api.Query);
     Assert.IsNotNull(items);
     Assert.IsTrue(items.Count > 0, "No items found");
 }
Beispiel #2
0
        private void BtnGetSearchResults_Click(object sender, System.EventArgs e)
        {
            try
            {
                LstSearchResults.Items.Clear();

                GetSearchResultsCall apicall = new GetSearchResultsCall(Context);

                if (ChkSearchDescription.Checked || ChkPayPal.Checked)
                    apicall.SearchFlagsList = new SearchFlagsCodeTypeCollection();

                if (ChkSearchDescription.Checked)
                    apicall.SearchFlagsList.Add(SearchFlagsCodeType.SearchInDescription);

                if (this.ChkPayPal.Checked)
                    apicall.SearchFlagsList.Add(SearchFlagsCodeType.PayPalBuyerPaymentOption);

                if (TxtPriceFrom.Text.Length > 0 && TxtPriceTo.Text.Length > 0)
                {
                    apicall.PriceRangeFilter = new PriceRangeFilterType();
                    apicall.PriceRangeFilter.MinPrice = new AmountType();
                    apicall.PriceRangeFilter.MaxPrice = new AmountType();
                    apicall.PriceRangeFilter.MinPrice.Value = Convert.ToDouble(TxtPriceFrom.Text);
                    apicall.PriceRangeFilter.MaxPrice.Value = Convert.ToDouble(TxtPriceTo.Text);
                }

                if (TxtCategory.Text.Length > 0)
                    apicall.CategoryID = TxtCategory.Text;

                apicall.Order = (SearchSortOrderCodeType)Enum.Parse(typeof(SearchSortOrderCodeType), CboSort.SelectedItem.ToString());

                SearchResultItemTypeCollection fnditems = apicall.GetSearchResults(TxtQuery.Text);

                foreach (SearchResultItemType fnditem in fnditems)
                {
                    string[] listparams = new string[5];
                    listparams[0] = fnditem.Item.ItemID;
                    listparams[1] = fnditem.Item.Title;
                    listparams[2] = fnditem.Item.SellingStatus.CurrentPrice.Value.ToString();
                    listparams[3] = fnditem.Item.SellingStatus.BidCount.ToString();
                    listparams[4] = DateTime.Now.ToString();

                    ListViewItem vi = new ListViewItem(listparams);
                    LstSearchResults.Items.Add(vi);

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }