コード例 #1
0
ファイル: AddItem.aspx.cs プロジェクト: fudder/cs493
        protected void BtnAddItem_Click(object sender, System.EventArgs e)
        {
            try
            {
                AttributesMaster attrMaster = (AttributesMaster)Session[Global.ATTRIBUTES_MASTER];

                //
                ApiContext asn = (ApiContext)Session[Global.APISESSION];
                AddItemCall api = new AddItemCall(asn);

                // Create the item
                ItemType item = new ItemType();

                item.Site = (SiteCodeType)Session[Global.SITE];
                item.Country = CountryCodeType.US;

                item.ListingType = (ListingTypeCodeType)Enum.Parse(typeof(ListingTypeCodeType),this.ddlListingType.SelectedValue.ToString());
                if(item.ListingType.Equals(ListingTypeCodeType.LeadGeneration))
                {
                    item.ListingSubtype2=ListingSubtypeCodeType.ClassifiedAd;
                }
                item.Title = this.ItemTitle.Text;
                item.Description = this.Description.Text;
                item.Currency = Global.GetCurrencyType(item.Site);

                if(this.StartPrice.Text!=string.Empty)
                {
                    item.StartPrice = new AmountType();
                    item.StartPrice.currencyID = item.Currency;
                    item.StartPrice.Value = Convert.ToDouble(this.StartPrice.Text);
                }

                if(this.BuyItNowPrice.Text!=string.Empty)
                {
                    item.BuyItNowPrice = new AmountType();
                    item.BuyItNowPrice.currencyID = item.Currency;
                    item.BuyItNowPrice.Value = Convert.ToDouble(this.BuyItNowPrice.Text);
                }

                item.Quantity = Int32.Parse(this.Quantity.Text);

                item.Location = this.ItemLocation.Text;
                item.ListingDuration = this.ItemDuration.SelectedItem.Value;

                ListingEnhancementsCodeTypeCollection enhancements = new ListingEnhancementsCodeTypeCollection();
                enhancements.Add(ListingEnhancementsCodeType.BoldTitle);
                item.ListingEnhancement = enhancements;

                // Set Attributes property.
                int catID = (int)Session["CategoryId"];
                item.PrimaryCategory = new CategoryType();
                item.PrimaryCategory.CategoryID = catID.ToString();

                catID = (int)Session["Category2Id"];
                if( catID != 0 )
                {
                    item.SecondaryCategory = new CategoryType();
                    item.SecondaryCategory.CategoryID = catID.ToString();
                }

                IAttributeSetCollection itemAttributes=null;
                if(Session[Global.ITEM_ATTR_SETS]!=null)
                {
                    itemAttributes = (IAttributeSetCollection)Session[Global.ITEM_ATTR_SETS];
                    item.AttributeSetArray = attrMaster.ConvertAttributeSetArray(itemAttributes);
                }
                if (Session[Global.CUSTOME_ITEM_SPECIFIC]!=null)
                {
                    item.ItemSpecifics=(NameValueListTypeCollection)Session[Global.CUSTOME_ITEM_SPECIFIC];
                }

                // Motor
                if( this.MotorSubtitle.Text.Length > 0 )
                {
                    MotorAttributeHelper mh = new MotorAttributeHelper(item.AttributeSetArray[0]);
                    mh.Subtitle = this.MotorSubtitle.Text;
                    if( this.MotorDepositAmount.Text.Length > 0 )
                        mh.DepositAmount = Decimal.Parse(this.MotorDepositAmount.Text);
                }

                if(ddlShippingServiceDetails.SelectedItem.Value != "None")
                {
                    //add shipping information
                    item.ShippingDetails=getShippingDetails(ddlShippingServiceDetails.SelectedItem.Value);
                }
                //add handling time
                item.DispatchTimeMax=1;
                //add return policy
                if(ltlReturnPolicyEnalbed.Text!=string.Empty&&ltlReturnPolicyEnalbed.Text==RETURN_POLICY_ENABLE)
                {
                    item.ReturnPolicy=getReturnPolicy();
                }

                //get shipping locations
                item.ShipToLocations=getShppingLocations();
                //set payments
                setPaymentMethods(item);

                FeeTypeCollection fees = api.AddItem(item);

                viewItemInfo(item);
            }
            catch(Exception ex)
            {
                this.StatusText.Text = ex.Message;
                this.StatusText.Visible = true;
            }
        }
コード例 #2
0
ファイル: AddItem.cs プロジェクト: jaskirat-danits/oswebshop
        //list to eBay
        private void addItem()
        {

            try
            {
                //
                ApiContext apiContext = this.controller.ApiContext;
                AddItemCall api = new AddItemCall(apiContext);

                // Create the item
                ItemType item = new ItemType();

                item.Site = apiContext.Site;
                item.Country = CountryCodeType.US;

                item.ListingType = (ListingTypeCodeType)Enum.Parse(typeof(ListingTypeCodeType), (this.listingTypeComboBox.SelectedItem as ListItem).Value);
                if (item.ListingType.Equals(ListingTypeCodeType.LeadGeneration))
                {
                    item.ListingSubtype2 = ListingSubtypeCodeType.ClassifiedAd;
                }
                item.Title = this.titleTextBox.Text;
                item.Description = this.descriptionTextBox.Text;
                item.Currency = this.getCurrencyType(item.Site);

                if (this.startPriceTextBox.Text != string.Empty)
                {
                    item.StartPrice = new AmountType();
                    item.StartPrice.currencyID = item.Currency;
                    item.StartPrice.Value = Convert.ToDouble(this.startPriceTextBox.Text);
                }

                if (this.binTextBox.Text != string.Empty)
                {
                    item.BuyItNowPrice = new AmountType();
                    item.BuyItNowPrice.currencyID = item.Currency;
                    item.BuyItNowPrice.Value = Convert.ToDouble(this.binTextBox.Text);
                }

                item.Quantity = Int32.Parse(this.quantityTextBox.Text);

                item.Location = this.locationTextBox.Text;
                item.ListingDuration = (this.durationComboBox.SelectedItem as ListItem).Value;

                ListingEnhancementsCodeTypeCollection enhancements = new ListingEnhancementsCodeTypeCollection();
                enhancements.Add(ListingEnhancementsCodeType.BoldTitle);
                item.ListingEnhancement = enhancements;


                // Set Item Condtion
                ConditionEnabledCodeType condition = this.controller.CategoryFacade.ConditionEnabled;
                if (condition == ConditionEnabledCodeType.Enabled ||
                    condition == ConditionEnabledCodeType.Required)
                {
                    ListItem li = this.conditionComboBox.SelectedItem as ListItem;
                    int conditionId = int.Parse(li.Value);
                    item.ConditionID = conditionId;
                }

                // Set Attributes property.
                item.PrimaryCategory = new CategoryType();
                item.PrimaryCategory.CategoryID = this.controller.CategoryFacade.CategoryID;
                
                if (this.controller.CategoryFacade.ItemSpecificEnabled == ItemSpecificsEnabledCodeType.Enabled &&
                    this.controller.CategoryFacade.ItemSpecificsCache != null)
                {
                    item.ItemSpecifics = this.controller.CategoryFacade.ItemSpecificsCache;
                }

                // Motor
                if (this.controller.ApiContext.Site == SiteCodeType.eBayMotors &&
                    this.subTitleTextBox.Text.Length > 0)
                {
                    MotorAttributeHelper mh = new MotorAttributeHelper(item.AttributeSetArray[0]);
                    mh.Subtitle = this.subTitleTextBox.Text;
                    if (this.depositAmountTextBox.Text.Length > 0)
                        mh.DepositAmount = Decimal.Parse(this.depositAmountTextBox.Text);
                }

                if ((this.shippingServiceComboBox.SelectedItem as ListItem).Value != "None")
                {
                    //add shipping information
                    item.ShippingDetails = getShippingDetails((this.shippingServiceComboBox.SelectedItem as ListItem).Value);
                }

                //add handling time
                item.DispatchTimeMax = 1;

                SellerProfilesType sellerProfile = new SellerProfilesType();
                //add return policy
                if (this.controller.CategoryFacade.ReturnPolicyEnabled)
                {
                    if (this.controller.CategoryFacade.ReturnPolicyProfileCache != null)
                    {
                        sellerProfile.SellerReturnProfile = this.controller.CategoryFacade.ReturnPolicyProfileCache;
                    }
                    else if (this.controller.CategoryFacade.ReturnPolicyCache != null)
                    {
                        item.ReturnPolicy = this.controller.CategoryFacade.ReturnPolicyCache;
                    }
                }
                if (paymentProfileIdTextBox.Text != "" || paymentProfileNameTextBox.Text != "")
                {
                    sellerProfile.SellerPaymentProfile = new SellerPaymentProfileType();
                    if (this.paymentProfileIdTextBox.Text != "")
                    {
                        sellerProfile.SellerPaymentProfile.PaymentProfileID = Int64.Parse(paymentProfileIdTextBox.Text);
                        sellerProfile.SellerPaymentProfile.PaymentProfileIDSpecified = true;
                    }
                    sellerProfile.SellerPaymentProfile.PaymentProfileName = paymentProfileNameTextBox.Text;
                }
                if (shippingProfileIdTextBox.Text != "" || shippingProfileNameTextBox.Text != "")
                {
                    sellerProfile.SellerShippingProfile = new SellerShippingProfileType();
                    if (this.shippingProfileIdTextBox.Text != "")
                    {
                        sellerProfile.SellerShippingProfile.ShippingProfileID = Int64.Parse(shippingProfileIdTextBox.Text);
                        sellerProfile.SellerShippingProfile.ShippingProfileIDSpecified = true;
                    }
                    sellerProfile.SellerShippingProfile.ShippingProfileName = shippingProfileNameTextBox.Text;
                }

                //get shipping locations
                item.ShipToLocations = getShppingLocations();
                //set payments
                setPaymentMethods(item);
                // set seller profiles
                item.SellerProfiles = sellerProfile;

                FeeTypeCollection fees = api.AddItem(item);

                viewItemInfo(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

        }