Exemple #1
0
        protected void ContinueButton_Click(object sender, EventArgs e)
        {
            // LOOP EACH ITEM ROW TO DETERMINE GIFT OPTIONS
            List <BasketItemGiftOption> giftOptions = new List <BasketItemGiftOption>();

            foreach (GridViewRow row in GiftItemsGrid.Rows)
            {
                GiftWrapChoices      wrapOptions   = (GiftWrapChoices)row.FindControl("GiftWrapChoices");
                int                  wrapStyleId   = wrapOptions.WrapStyleId;
                string               giftMessage   = wrapOptions.GiftMessage;
                BasketItemGiftOption optionItem    = new BasketItemGiftOption(_BasketItem, wrapStyleId, giftMessage);
                int                  existingIndex = giftOptions.IndexOf(optionItem);
                if (existingIndex > -1)
                {
                    giftOptions[existingIndex].Quantity++;
                }
                else
                {
                    giftOptions.Add(optionItem);
                }
            }

            // LOOP THROUGH GIFT OPTIONS AND UPDATE BASKET ITEMS
            Basket basket = AbleContext.Current.User.Basket;

            for (int i = 0; i < giftOptions.Count; i++)
            {
                BasketItemGiftOption giftOptionItem = giftOptions[i];
                if (i == 0)
                {
                    // FOR FIRST GIFT OPTION, UPDATE THE ORIGINAL BASKET ITEM
                    _BasketItem.Quantity    = giftOptionItem.Quantity;
                    _BasketItem.WrapStyleId = giftOptionItem.WrapStyleId;
                    _BasketItem.GiftMessage = giftOptionItem.GiftMessage;
                }
                else
                {
                    // FOR ADDTIONAL GIFT OPTIONS, CREATE COPIES OF THE ORIGINAL BASKET ITEM
                    BasketItem newItem = _BasketItem.Copy();
                    newItem.Quantity    = giftOptionItem.Quantity;
                    newItem.GiftMessage = giftOptionItem.GiftMessage;
                    newItem.WrapStyleId = giftOptionItem.WrapStyleId;
                    basket.Items.Add(newItem);
                }
            }

            // SAVE, COMBINE, AND RETURN TO THE SHIP METHODS PAGE
            basket.Save();
            IBasketService basketService = AbleContext.Resolve <IBasketService>();

            basketService.Combine(basket);
            Response.Redirect("ShipMethod.aspx");
        }
Exemple #2
0
            public override bool Equals(object obj)
            {
                BasketItemGiftOption other = (BasketItemGiftOption)obj;

                return(this.WrapStyleId.Equals(other.WrapStyleId) && this.GiftMessage.Equals(other.GiftMessage));
            }
Exemple #3
0
        protected void ContinueButton_Click(object sender, EventArgs e)
        {
            BasketItem basketItem = BasketItemDataSource.Load(AlwaysConvert.ToInt(GiftOptionsBasketItemId.Value));
            // LOOP EACH ITEM ROW TO DETERMINE GIFT OPTIONS
            List <BasketItemGiftOption> giftOptions = new List <BasketItemGiftOption>();

            foreach (GridViewRow row in GiftItemsGrid.Rows)
            {
                GiftWrapChoices wrapOptions = (GiftWrapChoices)row.FindControl("GiftWrapChoices");
                wrapOptions.BasketItemId = basketItem.Id;
                int    wrapStyleId = wrapOptions.WrapStyleId;
                string giftMessage = wrapOptions.GiftMessage;
                BasketItemGiftOption optionItem = new BasketItemGiftOption(basketItem, wrapStyleId, giftMessage);
                int existingIndex = giftOptions.IndexOf(optionItem);
                if (existingIndex > -1)
                {
                    giftOptions[existingIndex].Quantity++;
                }
                else
                {
                    giftOptions.Add(optionItem);
                }
            }

            // LOOP THROUGH GIFT OPTIONS AND UPDATE BASKET ITEMS
            Basket basket = AbleContext.Current.User.Basket;

            for (int i = 0; i < giftOptions.Count; i++)
            {
                BasketItemGiftOption giftOptionItem = giftOptions[i];
                if (i == 0)
                {
                    // FOR FIRST GIFT OPTION, UPDATE THE ORIGINAL BASKET ITEM
                    basketItem.Quantity    = giftOptionItem.Quantity;
                    basketItem.WrapStyleId = giftOptionItem.WrapStyleId;
                    basketItem.GiftMessage = giftOptionItem.GiftMessage;
                }
                else
                {
                    // FOR ADDTIONAL GIFT OPTIONS, CREATE COPIES OF THE ORIGINAL BASKET ITEM
                    BasketItem newItem = basketItem.Copy();
                    newItem.Quantity    = giftOptionItem.Quantity;
                    newItem.GiftMessage = giftOptionItem.GiftMessage;
                    newItem.WrapStyleId = giftOptionItem.WrapStyleId;
                    basket.Items.Add(newItem);
                }
            }

            // SAVE, COMBINE
            basket.Save();
            IBasketService basketService = AbleContext.Resolve <IBasketService>();

            basketService.Combine(basket);

            CartSummary.DataSource = GetBasketItems();
            CartSummary.DataBind();

            // NOW HIDE THE POPUP
            phGiftOptions.Visible = false;
            GiftOptionsPopup.Hide();
        }