Ejemplo n.º 1
0
        /// <summary>
        /// The process of the command
        /// </summary>
        /// <param name="commerceContext">
        /// The commerce context
        /// </param>
        /// <param name="query">
        /// The Query
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task <SuggestedCategoryTypeCollection> GetSuggestedCategories(CommerceContext commerceContext, string query)
        {
            using (var activity = CommandActivity.Start(commerceContext, this))
            {
                try
                {
                    var getSuggestedCategories = new eBay.Service.Call.GetSuggestedCategoriesCall(await GetEbayContext(commerceContext));
                    var result = getSuggestedCategories.GetSuggestedCategories(query);

                    //Instantiate the call wrapper class
                    //var apiCall = new eBay.Service.Call.GetCategoriesCall(); // GeteBayOfficialTimeCall(await GetEbayContext(commerceContext));

                    //Send the call to eBay and get the results
                    // var officialTime = apiCall.GetCategories();

                    return(result);
                }
                catch (Exception ex)
                {
                    commerceContext.Logger.LogError($"Ebay.GetCategories.Exception: Message={ex.Message}");
                    //await commerceContext.AddMessage("Error", "Ebay.GetCategories.Exception", new Object[] { ex }, ex.Message);
                }
                return(new SuggestedCategoryTypeCollection());
            }
        }
 public void GetSuggestedCategories()
 {
     GetSuggestedCategoriesCall api = new GetSuggestedCategoriesCall(this.apiContext);
     api.Query = "DVD";
     SuggestedCategoryTypeCollection cats = api.GetSuggestedCategories(api.Query);
     //check whether the call is success.
     Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success||api.ApiResponse.Ack == AckCodeType.Warning,"the call is failure!");
     Assert.IsNotNull(cats);
     Assert.IsTrue(cats.Count > 0);
     //check the category number is right
     Assert.AreEqual(cats.Count,api.ApiResponse.CategoryCount);
 }
Ejemplo n.º 3
0
        public async Task <SuggestedCategoryTypeCollection> GetSuggestedCategories(CommerceContext commerceContext, string query)
        {
            using (CommandActivity.Start(commerceContext, this))
            {
                try
                {
                    var getSuggestedCategories = new eBay.Service.Call.GetSuggestedCategoriesCall(await this.GetEbayContext(commerceContext));
                    var result = getSuggestedCategories.GetSuggestedCategories(query);

                    return(result);
                }
                catch (Exception ex)
                {
                    commerceContext.Logger.LogError($"Ebay.GetCategories.Exception: Message={ex.Message}");
                }
                return(new SuggestedCategoryTypeCollection());
            }
        }
Ejemplo n.º 4
0
        private void BtnGetSuggestedCategories_Click(object sender, System.EventArgs e)
        {
            try
            {
                LstCategories.Items.Clear();

                GetSuggestedCategoriesCall apicall = new GetSuggestedCategoriesCall(Context);

                SuggestedCategoryTypeCollection cats = apicall.GetSuggestedCategories(TxtQuery.Text);

                if (cats != null)
                {
                    foreach (SuggestedCategoryType category in cats)
                    {
                        string[] listparams = new string[3];
                        listparams[0] = category.Category.CategoryID;
                        listparams[1] = String.Join(" : ", category.Category.CategoryParentName.ToArray()) + " : " + category.Category.CategoryName;
                        listparams[2] =  category.PercentItemFound.ToString();

                        ListViewItem vi = new ListViewItem(listparams);
                        this.LstCategories.Items.Add(vi);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }