Example #1
0
        private ItemType FillItem()
        {
            BtnGetItem.Visible = false;

            ItemType item = new ItemType();

            // Set UP Defaults
            item.Currency = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
            item.Country  = SiteUtility.GetCountryCodeType(Context.Site);

            item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
            item.PaymentMethods.AddRange(new BuyerPaymentMethodCodeType[] { BuyerPaymentMethodCodeType.PayPal });
            item.RegionID = "0";

            // Set specified values from the form
            item.Title       = this.TxtTitle.Text;
            item.Description = this.TxtDescription.Text;

            item.Quantity = Int32.Parse(TxtQuantity.Text, NumberStyles.None);
            item.Location = TxtLocation.Text;

            item.ListingDuration = CboDuration.SelectedItem.ToString();


            item.PrimaryCategory            = new CategoryType();
            item.PrimaryCategory.CategoryID = this.TxtCategory.Text;;
            if (TxtStartPrice.Text.Length > 0)
            {
                item.StartPrice            = new AmountType();
                item.StartPrice.currencyID = item.Currency;
                item.StartPrice.Value      = Convert.ToDouble(this.TxtStartPrice.Text);
            }

            if (TxtReservePrice.Visible && TxtReservePrice.Text.Length > 0)
            {
                item.ReservePrice            = new AmountType();
                item.ReservePrice.currencyID = item.Currency;
                item.ReservePrice.Value      = Convert.ToDouble(this.TxtReservePrice.Text);
            }
            if (TxtBuyItNowPrice.Visible && TxtBuyItNowPrice.Text.Length > 0)
            {
                item.BuyItNowPrice            = new AmountType();
                item.BuyItNowPrice.currencyID = item.Currency;
                item.BuyItNowPrice.Value      = Convert.ToDouble(this.TxtBuyItNowPrice.Text);
            }

            ListingEnhancementsCodeTypeCollection enhancements = new ListingEnhancementsCodeTypeCollection();

            if (this.ChkBoldTitle.Checked)
            {
                enhancements.Add(ListingEnhancementsCodeType.BoldTitle);
            }
            if (this.ChkHighLight.Checked)
            {
                enhancements.Add(ListingEnhancementsCodeType.Highlight);
            }

            if (enhancements.Count > 0)
            {
                item.ListingEnhancement = enhancements;
            }

            item.ListingType = (ListingTypeCodeType)Enum.Parse(typeof(ListingTypeCodeType), CboListType.SelectedItem.ToString());

            if (ChkEnableBestOffer.Visible)
            {
                item.BestOfferDetails = new BestOfferDetailsType();
                item.BestOfferDetails.BestOfferEnabled = ChkEnableBestOffer.Checked;
            }

            if (TxtCategory2.Text.Length > 0)
            {
                item.SecondaryCategory            = new CategoryType();
                item.SecondaryCategory.CategoryID = TxtCategory2.Text;
            }

            if (TxtPayPalEmailAddress.Text.Length > 0)
            {
                item.PayPalEmailAddress = TxtPayPalEmailAddress.Text;
            }

            if (TxtApplicationData.Text.Length > 0)
            {
                item.ApplicationData = TxtApplicationData.Text;
            }

            int condition = ((ComboxItem)CboCondition.SelectedItem).Value;

            item.ConditionID = condition;

            //add shipping information
            item.ShippingDetails = getShippingDetails();
            //add handling time
            item.DispatchTimeMax = 1;
            //add policy
            item.ReturnPolicy = GetPolicyForUS();

            return(item);
        }