Example #1
0
        protected void WishlistGrid_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.CommandArgument.ToString()))
            {
                int      rowIndex       = AlwaysConvert.ToInt(e.CommandArgument);
                int      wishlistItemId = (int)WishlistGrid.DataKeys[rowIndex].Value;
                Wishlist wishlist       = AbleContext.Current.User.PrimaryWishlist;
                int      index          = wishlist.WishlistItems.IndexOf(wishlistItemId);
                switch (e.CommandName)
                {
                case "Basket":
                    if (index > -1)
                    {
                        wishlist.WishlistItems.MoveToBasket(index, AbleContext.Current.User.Basket);
                        Response.Redirect(NavigationHelper.GetBasketUrl());
                    }
                    WishlistGrid.DataBind();
                    break;

                case "DeleteItem":
                    if (index > -1)
                    {
                        wishlist.WishlistItems.DeleteAt(index);
                    }
                    WishlistGrid.DataBind();
                    break;
                }
            }
        }
Example #2
0
 private void BindWishlist()
 {
     WishlistGrid.DataSource = AbleContext.Current.User.PrimaryWishlist.WishlistItems;
     WishlistGrid.DataBind();
 }
Example #3
0
        protected void Page_Init(object sender, System.EventArgs e)
        {
            // CHECK IF WISHLISTS DISABLED
            if (!AbleContext.Current.Store.Settings.WishlistsEnabled)
            {
                WishlistCaption.Visible = false;
                WishlistMultiView.SetActiveView(WishlistDisabledView);
                return;
            }

            string strViewCode = Request.QueryString["ViewCode"];
            Guid   viewCode    = new Guid();

            if (Guid.TryParse(strViewCode, out viewCode))
            {
                _Wishlist = WishlistDataSource.LoadForViewCode(viewCode);
            }

            if (_Wishlist == null)
            {
                Response.Redirect(AbleCommerce.Code.NavigationHelper.GetHomeUrl());
                return;
            }

            _WishlistId = _Wishlist.Id;
            _Wishlist.Recalculate();
            IList <WishlistItem> items = _Wishlist.WishlistItems;
            Product      product;
            WishlistItem item;
            var          user   = AbleContext.Current.User;
            List <int>   groups = (from ug in AbleContext.Current.User.UserGroups select ug.GroupId).ToList <int>();

            for (int i = items.Count - 1; i >= 0; i--)
            {
                item    = items[i];
                product = item.Product;
                if (product == null || product.Visibility == CatalogVisibility.Private || isVariantInvalid(item))
                {
                    items.RemoveAt(i);
                }
                else if (!user.IsAdmin)
                {
                    if (product.EnableGroups)
                    {
                        if (groups.Count > 0)
                        {
                            bool isInGroup = product.ProductGroups.Any <ProductGroup>(pg => groups.Contains(pg.Group.Id));
                            if (!isInGroup)
                            {
                                items.RemoveAt(i);
                            }
                        }
                        else
                        {
                            items.RemoveAt(i);
                        }
                    }
                }
            }

            WishlistGrid.DataSource = items;
            WishlistGrid.DataBind();

            if (!string.IsNullOrEmpty(_Wishlist.ViewPassword))
            {
                string currentPassword = (string)Session["Wishlist" + _WishlistId.ToString() + "_Password"];
                if ((currentPassword == null) || (currentPassword != _Wishlist.ViewPassword))
                {
                    WishlistMultiView.SetActiveView(PasswordView);
                    AbleCommerce.Code.PageHelper.SetDefaultButton(Password, CheckPasswordButton.ClientID);
                }
            }
            if (WishlistMultiView.ActiveViewIndex == 0)
            {
                WishlistCaption.Text = string.Format(_Caption, GetUserName(_Wishlist.User));
            }
            else
            {
                WishlistCaption.Text = "Enter Wishlist Password";
            }
        }