Esempio n. 1
0
 private SearchSummary CreateSearchSummary(Search search)
 {
     return new SearchSummary()
     {
         Name = search.Name,
         Description = search.Description,
         Link = search.Link
     };
 }
Esempio n. 2
0
        private FindCompletedItemsRequest CreateCompletedItemsRequest(Search searchItem, int pageNumber)
        {
            // Completed items, new only
            var request = new FindCompletedItemsRequest();
            List<ItemFilter> filters = new List<ItemFilter>();

            // Search term
            foreach (SearchCriteria criteria in searchItem.SearchCriteria)
            {
                switch (criteria.Criteria)
                {
                    case "Title":
                        request.keywords = criteria.Value;
                        break;

                    case "Condition":
                        filters.Add(new ItemFilter() { name = ItemFilterType.Condition, value = new string[] { criteria.Value, "1000" } });
                        break;

                    case "SoldItemsOnly":
                        filters.Add(new ItemFilter() { name = ItemFilterType.SoldItemsOnly, value = new string[] { criteria.Value } });
                        break;

                    case "Currency":
                        filters.Add(new ItemFilter() { name = ItemFilterType.Currency, value = new string[] { criteria.Value } });
                        break;
                }
            }

            // Filters to specify new, sold and GBP
            // Wire up default values

            if (String.IsNullOrEmpty(request.keywords))
                request.keywords = searchItem.Name;

            if (filters.Find(f => f.name == ItemFilterType.Currency) == null)
                filters.Add(new ItemFilter() { name = ItemFilterType.Currency, value = new string[] { "GBP" } });

            //if (filters.Find(f => f.name == ItemFilterType.Condition) == null)
            //    filters.Add(new ItemFilter() { name = ItemFilterType.Condition, value = new string[] { "New" , "1000"} });

            if (filters.Find(f => f.name == ItemFilterType.SoldItemsOnly) == null)
                filters.Add(new ItemFilter() { name = ItemFilterType.SoldItemsOnly, value = new string[] { "True" } });

            // Have we recently updated ... if so, ask for items since we last updated
            if (searchItem.LastRun != null)
            {
                filters.Add(
                    new ItemFilter() { name = ItemFilterType.EndTimeFrom, value = new string[] { searchItem.LastRun.ToString("s") } }
                    );
            }

            // Add the page number
            request.paginationInput = new PaginationInput();
            request.paginationInput.pageNumber = pageNumber;
            request.paginationInput.pageNumberSpecified = true;

            request.itemFilter = filters.ToArray();
            request.sortOrder = SortOrderType.EndTimeSoonest;

            return request;
        }