Пример #1
0
    protected void uxAddToCartButton_Click(object sender, EventArgs e)
    {
        PromotionSelected promotion = new PromotionSelected(StoreContext.Culture, new StoreRetriever().GetCurrentStoreID());

        promotion.SetPromotionGroupID = PromotionGroupID;
        bool isSuccess = true;

        foreach (DataListItem item in uxList.Items)
        {
            if (item.FindControl("uxGroup") != null)
            {
                Mobile_Components_PromotionProductGroup group = (Mobile_Components_PromotionProductGroup)item.FindControl("uxGroup");
                if (group.IsSelectedProduct)
                {
                    string   productGroup = group.GetSelectedOption;
                    string[] groupInfo    = productGroup.Split(':');

                    IList <string> options = new List <string>();
                    foreach (string option in groupInfo[1].Split(','))
                    {
                        if (option.Trim() == "")
                        {
                            continue;
                        }
                        options.Add(option);
                    }
                    Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, groupInfo[0], new StoreRetriever().GetCurrentStoreID());
                    promotion.AddSelectedPromotionItem(group.PromotionSubGroupID, product, options);
                }
                else
                {
                    isSuccess = false;
                }
            }
        }
        if (!isSuccess)
        {
            return;
        }

        // Check Inventory
        isSuccess = CheckOutOfStock(promotion.PromotionSelectedItems);
        if (!isSuccess)
        {
            return;
        }
        // Check Free Shipping
        isSuccess = PromotionSelected.CheckCanAddItemToCart(StoreContext.ShoppingCart, promotion);
        if (isSuccess)
        {
            PromotionSelected.AddPromotionItem(StoreContext.ShoppingCart, promotion, 1);
            Response.Redirect("ShoppingCart.aspx");
        }
        else
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + promotion.GetPromotionGroup().PromotionGroupID);
        }
    }
Пример #2
0
    public void Reload()
    {
        PopulateControl();

        foreach (DataListItem item in uxList.Items)
        {
            if (item.FindControl("uxGroup") != null)
            {
                Mobile_Components_PromotionProductGroup productGroup = (Mobile_Components_PromotionProductGroup)item.FindControl("uxGroup");
                productGroup.Reload();
            }
        }
    }