/// <summary>
        /// Move the basket item at the given index to the given wishlist
        /// </summary>
        /// <param name="index">Index of the item to move</param>
        /// <param name="wishlist">The wishlist to move to</param>
        public void MoveToWishlist(int index, Wishlist wishlist)
        {
            BasketItem item = this[index];

            wishlist.Items.Add(item);
            wishlist.Save();
            this.DeleteAt(index);
        }
Пример #2
0
        protected void SaveButton_Click(object sender, System.EventArgs e)
        {
            WishlistPasswordValue.Text = StringHelper.StripHtml(WishlistPasswordValue.Text);
            Wishlist w = AbleContext.Current.User.PrimaryWishlist;

            w.ViewPassword = WishlistPasswordValue.Text;
            w.IsPublic     = WishlistIsPublic.Checked;
            w.Save();
            WishlistPasswordUpdatedMessage.Visible = true;
        }
Пример #3
0
        private void SaveWishlist()
        {
            Wishlist wishlist = AbleContext.Current.User.PrimaryWishlist;
            int      rowIndex = 0;

            foreach (GridViewRow saverow in WishlistGrid.Rows)
            {
                int wishlistItemId = (int)WishlistGrid.DataKeys[rowIndex].Value;
                int itemIndex      = wishlist.WishlistItems.IndexOf(wishlistItemId);
                if (itemIndex > -1)
                {
                    WishlistItem item    = wishlist.WishlistItems[itemIndex];
                    TextBox      desired = saverow.FindControl("Desired") as TextBox;
                    if (desired != null)
                    {
                        item.Desired = AlwaysConvert.ToInt16(desired.Text, item.Desired);
                        if (item.Desired <= 0)
                        {
                            item.Delete();
                        }
                    }
                    DropDownList priority = saverow.FindControl("Priority") as DropDownList;
                    if (priority != null)
                    {
                        item.Priority = AlwaysConvert.ToByte(priority.SelectedValue);
                        if (item.Priority < 0)
                        {
                            item.Priority = 0;
                        }
                        if (item.Priority > 4)
                        {
                            item.Priority = 4;
                        }
                    }
                    TextBox comment = saverow.FindControl("Comment") as TextBox;
                    if (comment != null)
                    {
                        item.Comment = StringHelper.StripHtml(comment.Text);
                    }
                    rowIndex++;
                }
            }
            wishlist.Save();
        }
        protected void AcceptButton_Click(object sender, EventArgs e)
        {
            this.DisplayIndex++;
            if (this.DisplayIndex < _LicenseAgreementIds.Length)
            {
                //SHOW THE NEXT AGREEMENT
                UpdateAgreementText();
            }
            else
            {
                //ALL AGREEMENTS HAVE BEEN ACCEPTED
                //CLEAR ITEMS FROM APPLICATION CACHE
                Cache.Remove(_CacheKey);
                bool addToWishlist = AlwaysConvert.ToBool(Request.QueryString["ToWishlist"], false);

                if (addToWishlist)
                {
                    Wishlist wishlist = AbleContext.Current.User.PrimaryWishlist;
                    foreach (BasketItem item in _BasketItems)
                    {
                        wishlist.WishlistItems.Add(item);
                    }
                    wishlist.Save();
                }
                else
                {
                    //ADD PRODUCTS TO BASKET
                    Basket basket = AbleContext.Current.User.Basket;
                    foreach (BasketItem item in _BasketItems)
                    {
                        basket.Items.Add(item);
                    }
                    basket.Save();
                }
                //ROUTE TO ACCEPT URL
                Response.Redirect(AcceptUrl);
            }
        }
Пример #5
0
        protected void VariantGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string optionList;

            if (e.CommandName.Equals("AddToBasket"))
            {
                optionList = e.CommandArgument.ToString();
                ProductVariant variant = _VariantManager.GetVariantFromOptions(optionList);
                if (variant != null)
                {
                    BasketItem basketItem = GetBasketItem(optionList, e);
                    if (basketItem != null)
                    {
                        // DETERMINE IF THE LICENSE AGREEMENT MUST BE REQUESTED
                        IList <LicenseAgreement> basketItemLicenseAgreements = new List <LicenseAgreement>();
                        basketItemLicenseAgreements.BuildCollection(basketItem, LicenseAgreementMode.OnAddToBasket);
                        if ((basketItemLicenseAgreements.Count > 0))
                        {
                            // THESE AGREEMENTS MUST BE ACCEPTED TO ADD TO CART
                            List <BasketItem> basketItems = new List <BasketItem>();
                            basketItems.Add(basketItem);
                            string guidKey = Guid.NewGuid().ToString("N");
                            Cache.Add(guidKey, basketItems, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 10, 0), System.Web.Caching.CacheItemPriority.NotRemovable, null);
                            string acceptUrl  = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("~/Basket.aspx"));
                            string declineUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(Page.ResolveUrl(_Product.NavigateUrl)));
                            Response.Redirect("~/BuyWithAgreement.aspx?Items=" + guidKey + "&AcceptUrl=" + acceptUrl + "&DeclineUrl=" + declineUrl);
                        }

                        //ADD ITEM TO BASKET
                        Basket basket = AbleContext.Current.User.Basket;
                        basket.Items.Add(basketItem);
                        basket.Save();

                        //Determine if there are associated Upsell products
                        if (basketItem.Product.GetUpsellProducts(basket).Count > 0)
                        {
                            //redirect to upsell page
                            string returnUrl = AbleCommerce.Code.NavigationHelper.GetEncodedReturnUrl();
                            Response.Redirect("~/ProductAccessories.aspx?ProductId=" + basketItem.Product.Id + "&ReturnUrl=" + returnUrl);
                        }

                        // IF BASKET HAVE SOME VALIDATION PROBLEMS MOVE TO BASKET PAGE
                        IBasketService     service  = AbleContext.Resolve <IBasketService>();
                        ValidationResponse response = service.Validate(basket);
                        if (!response.Success)
                        {
                            Session["BasketMessage"] = response.WarningMessages;
                            Response.Redirect(AbleCommerce.Code.NavigationHelper.GetBasketUrl());
                        }

                        //IF THERE IS NO REGISTERED BASKET CONTROL, WE MUST GO TO BASKET PAGE
                        if (!AbleCommerce.Code.PageHelper.HasBasketControl(this.Page))
                        {
                            Response.Redirect(AbleCommerce.Code.NavigationHelper.GetBasketUrl());
                        }
                    }
                }
            }
            if (e.CommandName.Equals("AddToWishlist"))
            {
                optionList = e.CommandArgument.ToString();
                ProductVariant variant = _VariantManager.GetVariantFromOptions(optionList);
                if (variant != null)
                {
                    BasketItem wishlistItem = GetBasketItem(optionList, e);
                    if (wishlistItem != null)
                    {
                        Wishlist wishlist = AbleContext.Current.User.PrimaryWishlist;
                        wishlist.WishlistItems.Add(wishlistItem);
                        wishlist.Save();
                        Response.Redirect("~/Members/MyWishlist.aspx");
                    }
                }
            }

            else if (e.CommandName.Equals("NotifyMe"))
            {
                HtmlTableRow row = (HtmlTableRow)((Control)e.CommandSource).Parent.Parent;
                optionList = e.CommandArgument.ToString();
                string         email             = GetInputControlValue(row, "EmailText");
                Label          subscribedMessage = (Label)PageHelper.RecursiveFindControl(row, "messageLabel");
                LinkButton     notifyLink        = (LinkButton)PageHelper.RecursiveFindControl(row, "NotificationLink");
                ProductVariant variant           = _VariantManager.GetVariantFromOptions(optionList);

                if (RestockNotifyDataSource.LoadVariantForEmail(variant.Id, email) == null)
                {
                    RestockNotify notification = new RestockNotify(_Product, variant, email);
                    notification.Save();

                    subscribedMessage.Text    = string.Format(subscribedMessage.Text, email);
                    subscribedMessage.Visible = true;
                    notifyLink.Visible        = false;
                }
                else if (!string.IsNullOrEmpty(email))
                {
                    subscribedMessage.Text    = string.Format(subscribedMessage.Text, email);
                    subscribedMessage.Visible = true;
                    notifyLink.Visible        = false;
                }
            }
        }