public FindItemsByKeywordsResponse SearchItems(string query, int pageSize, int pageNumber, dynamic filterList)
    {
        // Creating an object to the BestMatchService class
        CustomFindingService service = new CustomFindingService();
        service.Url = ConfigurationManager.AppSettings["FindingService"];

        // Creating request object for FindBestMatchItemDetailsByKeywords API
        FindItemsByKeywordsRequest request = new FindItemsByKeywordsRequest();

        // Setting the required property values
        request.keywords = query;

        // Setting the pagination
        PaginationInput pagination = new PaginationInput();
        pagination.entriesPerPageSpecified = true;
        pagination.entriesPerPage = pageSize;
        pagination.pageNumberSpecified = true;
        pagination.pageNumber = pageNumber;
        request.paginationInput = pagination;

        ItemFilter[] filters = new ItemFilter[4];

        ItemFilter filter = new ItemFilter();
        filter.name = ItemFilterType.ListingType;
        filter.value = new string[] { "FixedPrice", "StoreInventory" };

        ItemFilter filter3 = new ItemFilter();
        filter3.name = ItemFilterType.MinPrice;
        filter3.value = new string[] { filterList["MinPrice"] };

        filters[0] = filter;
        filters[1] = filter3;

        if (int.Parse(filterList["MinQuantity"]) > 0)
        {
            ItemFilter filter2 = new ItemFilter();
            filter2.name = ItemFilterType.MinQuantity;
            filter2.value = new string[] { filterList["MinQuantity"] };
            filters[2] = filter2;
        }

        if (filterList["IsNew"] == true)
        {
            ItemFilter filter4 = new ItemFilter();
            filter4.name = ItemFilterType.Condition;
            filter4.value = new string[] { "New" };
            filters[3] = filter4;
        }

        request.itemFilter = filters;

        request.sortOrder = SortOrderType.BestMatch;
        request.sortOrderSpecified = true;

        // Creating response object
        FindItemsByKeywordsResponse response = service.findItemsByKeywords(request);
        return response;
    }
    public FindItemsByKeywordsResponse SearchItems(SellerItem sellerItem, int pageSize, int pageNumber)
    {
        // Creating an object to the BestMatchService class
        CustomFindingService service = new CustomFindingService();
        service.Url = ConfigurationManager.AppSettings["FindingService"];

        // Creating request object for FindBestMatchItemDetailsByKeywords API
        FindItemsByKeywordsRequest request = new FindItemsByKeywordsRequest();

        // Setting the required property values
        request.keywords = sellerItem.Keywords;

        // Setting the pagination
        PaginationInput pagination = new PaginationInput();
        pagination.entriesPerPageSpecified = true;
        pagination.entriesPerPage = pageSize;
        pagination.pageNumberSpecified = true;
        pagination.pageNumber = pageNumber;
        request.paginationInput = pagination;
        ItemFilter filter;
        List<ItemFilter> filters = new List<ItemFilter>();

        /*ListingType*/
        string ListingTypeFilter = null;
        if (sellerItem.Is_Fixed_Price == true)
            ListingTypeFilter = "FixedPrice";

        if (sellerItem.Is_Auctions == true)
            ListingTypeFilter += ",AuctionWithBIN";

        if (ListingTypeFilter != null)
        {
            filter = new ItemFilter();
            filter.name = ItemFilterType.ListingType;
            filter.value = ListingTypeFilter.Split(',');
            filters.Add(filter);
        }

        /*ReturnsAcceptedOnly*/
        if (sellerItem.Is_Returns_Accepted == true)
        {
            filter = new ItemFilter();
            filter.name = ItemFilterType.ReturnsAcceptedOnly;
            filter.value = new string[] { "true" };
            filters.Add(filter);
        }

        /*LocatedIn*/
        //if (sellerItem.Is_Location_AU == true)
        //{
        //    filter = new ItemFilter();
        //    filter.name = ItemFilterType.LocatedIn;
        //    filter.value = new string[] { "AU" };
        //    filters.Add(filter);
        //}
        if (!string.IsNullOrEmpty(sellerItem.LocatedIn))
        {
            filter = new ItemFilter();
            filter.name = ItemFilterType.LocatedIn;
            filter.value = new string[] { sellerItem.LocatedIn.ToUpper() };
            filters.Add(filter);
        }
        /*HideDuplicateItems*/
        if (sellerItem.Is_Hide_Duplicates == true)
        {
            filter = new ItemFilter();
            filter.name = ItemFilterType.HideDuplicateItems;
            filter.value = new string[] { "true" };
            filters.Add(filter);
        }
        /*TopRatedSellerOnly*/
        if (sellerItem.Is_Hide_Duplicates == true)
        {
            filter = new ItemFilter();
            filter.name = ItemFilterType.TopRatedSellerOnly;
            filter.value = new string[] {"true"};
            filters.Add(filter);
        }
        else
        {
            /*Specify one or more seller names. Search results will
             include items from the specified sellers only.
             The Seller item filter cannot be used together with either the
             ExcludeSeller or TopRatedSellerOnly item filters. */
            if (!string.IsNullOrEmpty(sellerItem.Inclued_Sellers))
            {
                filter = new ItemFilter();
                filter.name = ItemFilterType.Seller;
                filter.value = sellerItem.Inclued_Sellers.Split(',');
                filters.Add(filter);
            }
            else if (!string.IsNullOrEmpty(sellerItem.Exclude_Sellers))
            {
                filter = new ItemFilter();
                filter.name = ItemFilterType.ExcludeSeller;
                filter.value = sellerItem.Exclude_Sellers.Split(',');
                filters.Add(filter);
            }
        }
        /*MinQuantity*/
        if (sellerItem.Minimum_Quantity > 0)
        {
            filter = new ItemFilter();
            filter.name = ItemFilterType.MinQuantity;
            filter.value = new string[] { sellerItem.Minimum_Quantity.ToString() };
            filters.Add(filter);
        }
        /*MaxQuantity*/
        if (sellerItem.Maximum_Quantity > 0)
        {
            filter = new ItemFilter();
            filter.name = ItemFilterType.MaxQuantity;
            filter.value = new string[] { sellerItem.Maximum_Quantity.ToString() };
            filters.Add(filter);
        }
        /*MinPrice*/
        if (sellerItem.Minimum_Price >= 0)
        {
            filter = new ItemFilter();
            filter.name = ItemFilterType.MinPrice;
            filter.value = new string[] { sellerItem.Minimum_Price.ToString() };
            filters.Add(filter);
        }
        /*MaxPrice*/
        if (sellerItem.Maximum_Price > 0)
        {
            filter = new ItemFilter();
            filter.name = ItemFilterType.MaxPrice;
            filter.value = new string[] { sellerItem.Maximum_Price.ToString() };
            filters.Add(filter);
        }
        /*FeedbackScoreMin*/
        if (sellerItem.Minimum_Feedback >= 0)
        {
            filter = new ItemFilter();
            filter.name = ItemFilterType.FeedbackScoreMin;
            filter.value = new string[] {sellerItem.Minimum_Feedback.ToString()};
            filters.Add(filter);
        }
        /*FeedbackScoreMax*/
        if (sellerItem.Maximum_Feedback > 0)
        {
            filter = new ItemFilter();
            filter.name = ItemFilterType.FeedbackScoreMax;
            filter.value = new string[] { sellerItem.Maximum_Feedback.ToString() };
            filters.Add(filter);
        }
        /*Condition*/
        if (!string.IsNullOrEmpty(sellerItem.Include_Condtion_Codes))
        {
            filter = new ItemFilter();
            filter.name = ItemFilterType.Condition;
            filter.value = sellerItem.Include_Condtion_Codes.Split(',');
            filters.Add(filter);
        }
        /*Cateogry*/
        if (!string.IsNullOrEmpty(sellerItem.Exclude_Category_Codes))
        {
            filter = new ItemFilter();
            filter.name = ItemFilterType.ExcludeCategory;
            filter.value = sellerItem.Exclude_Category_Codes.Split(',');
            filters.Add(filter);
        }

        if(filters.Count > 0)
            request.itemFilter = filters.ToArray();
        request.sortOrder = SortOrderType.BestMatch;
        request.sortOrderSpecified = true;
        // Creating response object
        FindItemsByKeywordsResponse response = service.findItemsByKeywords(request);
        return response;
    }
    public FindItemsByKeywordsResponse SearchItemsByID(string ItemID)
    {
        // Creating an object to the BestMatchService class
        CustomFindingService service = new CustomFindingService();
        service.Url = ConfigurationManager.AppSettings["FindingService"];

        // Creating request object for FindBestMatchItemDetailsByKeywords API
        FindItemsByKeywordsRequest request = new FindItemsByKeywordsRequest();

        // Setting the required property values
        request.keywords = ItemID;

        // Setting the pagination
        PaginationInput pagination = new PaginationInput();
        pagination.entriesPerPageSpecified = true;
        pagination.entriesPerPage = 10;
        pagination.pageNumberSpecified = true;
        pagination.pageNumber = 1;
        request.paginationInput = pagination;

        List<ItemFilter> filters = new List<ItemFilter>();

        ItemFilter filter = new ItemFilter();
        filter.name = ItemFilterType.ListingType;
        filter.value = new string[] { "FixedPrice", "AuctionWithBIN" };
        filters.Add(filter);

        request.itemFilter = filters.ToArray();

        request.sortOrder = SortOrderType.BestMatch;
        request.sortOrderSpecified = true;

        // Creating response object
        FindItemsByKeywordsResponse response = service.findItemsByKeywords(request);
        return response;
    }