Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (ProductID != "0")
     {
         Product             product          = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, ProductID, StoreContext.CurrentStore.StoreID);
         ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);
         if (subscriptionItem.IsSubscriptionProduct())
         {
             uxInvalidSubscriptionPanel.Visible = true;
         }
         else
         {
             uxInvalidSubscriptionPanel.Visible = false;
             if (StoreContext.ShoppingCart.ContainsFreeShippingCostProduct() || CartItemPromotion.ContainsFreeShippingCostProductInBundlePromotion(StoreContext.ShoppingCart))
             {
                 uxProductFreeShippingCostPanel.Visible    = true;
                 uxProductNonFreeShippingCostPanel.Visible = false;
             }
             else
             {
                 uxProductNonFreeShippingCostPanel.Visible = true;
                 uxProductFreeShippingCostPanel.Visible    = false;
             }
         }
     }
     else
     {
         uxProductNonFreeShippingCostPanel.Visible = false;
         uxProductFreeShippingCostPanel.Visible    = false;
     }
 }
Ejemplo n.º 2
0
    private bool IsProductValid(Product product)
    {
        bool result = true;

        ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);

        if (subscriptionItem.IsSubscriptionProduct())
        {
            uxMessage.DisplayError("Cannot Add Subscription Product.");
            result = false;
        }
        else if (product.IsDownloadable)
        {
            uxMessage.DisplayError("Cannot Add Downloable Product.");
            result = false;
        }
        else if (product.IsRecurring)
        {
            uxMessage.DisplayError("Cannot Add Recurring Product.");
            result = false;
        }
        else if (product.IsGiftCertificate)
        {
            uxMessage.DisplayError("Cannot Add Gift Certificate product.");
            result = false;
        }
        else if (product.IsProductKit)
        {
            uxMessage.DisplayError("Cannot Add Product Kit.");
            result = false;
        }

        return(result);
    }
    protected void Page_PreRender(object sender, EventArgs e)
    {
        uxContinueLink.NavigateUrl =
            "GiftRegistryItem.aspx?GiftRegistryID=" + StoreContext.CheckoutDetails.GiftRegistryID;

        uxContinueLink.Visible           = false;
        giftRegistryMessagePanel.Visible = false;
        if (ProductID != "0")
        {
            Product             product          = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, ProductID, StoreContext.CurrentStore.StoreID);
            ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);
            if (subscriptionItem.IsSubscriptionProduct())
            {
                uxMessage.DisplayError("Cannot add product to the cart.<br/><br/>You already have higher product subscription level.");
            }
            else
            {
                if (StoreContext.ShoppingCart.ContainsFreeShippingCostProduct() || CartItemPromotion.ContainsFreeShippingCostProductInBundlePromotion(StoreContext.ShoppingCart))
                {
                    uxMessage.DisplayError("Cannot add product to the cart.<br/><br/>The shopping cart already has one or more product " +
                                           "that is a free shipping product.");
                    uxProductNonFreeShippingCostPanel.Visible = false;
                }
                else
                {
                    uxMessage.DisplayError("Cannot add product to the cart.<br/><br/>The shopping cart already has one or more product " +
                                           "that is not a free shipping.");
                    uxProductFreeShippingCostPanel.Visible = false;
                }
            }
        }
        else
        {
            if (FreeShipping != "0")
            {
                if (StoreContext.ShoppingCart.ContainsFreeShippingCostProduct() || CartItemPromotion.ContainsFreeShippingCostProductInBundlePromotion(StoreContext.ShoppingCart))
                {
                    uxProductFreeShippingCostPanel.Visible    = true;
                    uxProductNonFreeShippingCostPanel.Visible = false;
                }
                else
                {
                    uxProductNonFreeShippingCostPanel.Visible = true;
                    uxProductFreeShippingCostPanel.Visible    = false;
                }
            }
            else if (PromotionStock != "0")
            {
                uxMessage.DisplayError("Cannot add Promotional product to the cart because it is out of stock.");
            }
            else
            {
                uxContinueLink.Visible           = true;
                giftRegistryMessagePanel.Visible = true;
                uxMessage.DisplayError("Failed adding product to the cart.<br/><br/>The shopping cart already has one or more gift registry item(s).<br/><br/>" +
                                       "Please add more items using gift registry item list menu.");
            }
        }
    }
Ejemplo n.º 4
0
    protected void uxAddToCartImageButton_Click(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(ProductID))
        {
            ProductID = uxProductHidden.Value;
        }

        ProductSubscription subscriptionItem = new ProductSubscription(CurrentProduct.ProductID);

        if (subscriptionItem.IsSubscriptionProduct())
        {
            if (StoreContext.Customer.IsNull)
            {
                Response.Redirect("~/UserLogin.aspx?ReturnUrl=AddtoCart.aspx?ProductID=" + CurrentProduct.ProductID);
            }

            if (CustomerSubscription.IsContainsProductSubscriptionHigherLevel(
                    subscriptionItem.ProductSubscriptions[0].SubscriptionLevelID,
                    DataAccessContextDeluxe.CustomerSubscriptionRepository.GetCustomerSubscriptionsByCustomerID(StoreContext.Customer.CustomerID)))
            {
                Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + CurrentProduct.ProductID);
            }
        }

        if (!StoreContext.ShoppingCart.CheckCanAddItemToCart(CurrentProduct))
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + CurrentProduct.ProductID);
        }

        if (StoreContext.CheckoutDetails.ContainsGiftRegistry())
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx");
        }
        else
        {
            DataListItem item = uxList.Items[0];

            string errorMessage = String.Empty;
            if (VerifyValidInput(item, out errorMessage) &&
                IsMatchQuantity(item, out errorMessage))
            {
                AddItemToShoppingCart(item, out errorMessage);
            }

            if (!String.IsNullOrEmpty(errorMessage))
            {
                uxMessage.DisplayError(errorMessage);
                uxQuickViewButton.CommandArgument = "show";
            }
            else
            {
                uxMessage.ClearMessage();
                uxQuickViewButton.CommandArgument = "hide";
                uxUpdatePanel.Update();
            }
        }
    }
Ejemplo n.º 5
0
    protected void uxAddToCartImageButton_Command(object sender, CommandEventArgs e)
    {
        string productID = e.CommandArgument.ToString();
        string urlName   = e.CommandName.ToString();

        Product product = DataAccessContext.ProductRepository.GetOne(
            StoreContext.Culture,
            productID, new StoreRetriever().GetCurrentStoreID());

        ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);

        if (subscriptionItem.IsSubscriptionProduct())
        {
            if (StoreContext.Customer.IsNull)
            {
                string returnUrl = "AddtoCart.aspx?ProductID=" + product.ProductID;
                Response.Redirect("~/UserLogin.aspx?ReturnUrl=" + returnUrl);
            }
        }

        if (!StoreContext.ShoppingCart.CheckCanAddItemToCart(product))
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + productID);
        }

        if (StoreContext.CheckoutDetails.ContainsGiftRegistry())
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx");
        }
        else
        {
            if ((product.RequiresUserInput() || product.IsCustomPrice || product.IsProductKit))
            {
                Response.Redirect(UrlManager.GetProductUrl(productID, urlName));
            }
            else
            {
                StoreContext.ShoppingCart.AddItem(product, product.MinQuantity);

                bool enableNotification = ConvertUtilities.ToBoolean(DataAccessContext.Configurations.GetValue("EnableAddToCartNotification", StoreContext.CurrentStore));
                if (UrlManager.IsMobileDevice(Request))
                {
                    enableNotification = false;
                }
                if (enableNotification)
                {
                    uxAddToCartNotification.Show(product, product.MinQuantity);
                }
                else
                {
                    Response.Redirect("ShoppingCart.aspx");
                }
            }
        }
    }
    protected void uxAddItemButton_Command(object sender, CommandEventArgs e)
    {
        string  productID = e.CommandArgument.ToString();
        Product product   = DataAccessContext.ProductRepository.GetOne(
            uxLanguageControl.CurrentCulture, productID, SelectedStoreID);

        ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);

        if (subscriptionItem.IsSubscriptionProduct())
        {
            if (CustomerSubscription.IsContainsProductSubscriptionHigherLevel(
                    subscriptionItem.ProductSubscriptions[0].SubscriptionLevelID,
                    DataAccessContextDeluxe.CustomerSubscriptionRepository.GetCustomerSubscriptionsByCustomerID(SelectedCustomerID)))
            {
                uxMessage.DisplayError(
                    "Cannot add product to the cart. This customer already has higer product subscription level.");
                return;
            }
        }

        if (StoreContext.ShoppingCart.CheckCanAddItemToCart(product))
        {
            uxProductItemDetails.StoreID      = SelectedStoreID;
            uxProductItemDetails.CultureID    = uxLanguageControl.CurrentCulture.CultureID;
            uxProductItemDetails.ProductID    = productID;
            uxProductItemDetails.CurrencyCode = uxCurrencyControl.CurrentCurrencyCode;
            uxProductItemDetails.PopulateControls();
            uxAddItemPanel.Visible     = true;
            uxUpdateItemButton.Visible = false;
            uxAddItemButton.Visible    = true;
            uxAddItemButtonModalPopup.Show();

            if (uxProductItemDetails.IsProductKit(productID))
            {
                uxAddItemButton.Visible    = false;
                uxUpdateItemButton.Visible = false;
            }
        }
        else
        {
            if (product.FreeShippingCost)
            {
                uxMessage.DisplayError(
                    "Cannot add product to the cart. The shopping cart already has one or more product that not free shipping.");
            }
            else
            {
                uxMessage.DisplayError(
                    "Cannot add product to the cart. The shopping cart already has one or more product that is a free shipping product.");
            }
        }
    }
Ejemplo n.º 7
0
        public void Can_create_productSubscription()
        {
            var productSubscription = new ProductSubscription
            {
                Id        = 1,
                ProductId = 1,
                SupplierSubscriptionId = 1
            };

            Assert.Equal(1, productSubscription.ProductId);
            Assert.Equal(1, productSubscription.SupplierSubscriptionId);
            Assert.True(productSubscription.IsActive);
        }
Ejemplo n.º 8
0
    private void AddItemToShoppingCartWithoutOption(Product product)
    {
        if (product.RequiresUserInput() || product.IsCustomPrice || product.IsProductKit)
        {
            Response.Redirect(UrlManager.GetProductUrl(product.ProductID, product.UrlName));
        }
        else
        {
            ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);
            StoreContext.ShoppingCart.AddItem(product, product.MinQuantity, subscriptionItem.IsSubscriptionProduct());

            Response.Redirect("ShoppingCart.aspx");
        }
    }
Ejemplo n.º 9
0
    protected void uxAddToCartImageButton_Click(object sender, EventArgs e)
    {
        ProductSubscription subscriptionItem = new ProductSubscription(CurrentProduct.ProductID);

        if (subscriptionItem.IsSubscriptionProduct())
        {
            if (StoreContext.Customer.IsNull)
            {
                string returnUrl = "AddtoCart.aspx?ProductID=" + CurrentProduct.ProductID;
                Response.Redirect("~/UserLogin.aspx?ReturnUrl=" + returnUrl);
            }

            if (CustomerSubscription.IsContainsProductSubscriptionHigherLevel(
                    subscriptionItem.ProductSubscriptions[0].SubscriptionLevelID,
                    DataAccessContextDeluxe.CustomerSubscriptionRepository.GetCustomerSubscriptionsByCustomerID(StoreContext.Customer.CustomerID)))
            {
                Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + CurrentProduct.ProductID);
            }
        }

        if (!StoreContext.ShoppingCart.CheckCanAddItemToCart(CurrentProduct))
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + CurrentProduct.ProductID);
        }

        if (StoreContext.CheckoutDetails.ContainsGiftRegistry())
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx");
        }
        else
        {
            string errorMessage = String.Empty;
            if (VerifyValidInput(out errorMessage))
            {
                if (IsMatchQuantity())
                {
                    AddItemToShoppingCart();
                }
            }
            else
            {
                if (errorMessage != String.Empty)
                {
                    uxMessage.Text       = errorMessage;
                    uxMessageDiv.Visible = true;
                }
            }
        }
    }
    protected void uxAddToCartImageButton_Command(object sender, CommandEventArgs e)
    {
        string productID = e.CommandArgument.ToString();
        string urlName   = e.CommandName.ToString();

        Product product = DataAccessContext.ProductRepository.GetOne(
            StoreContext.Culture,
            productID, new StoreRetriever().GetCurrentStoreID());

        ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);

        if (subscriptionItem.IsSubscriptionProduct())
        {
            if (StoreContext.Customer.IsNull)
            {
                string returnUrl = "AddtoCart.aspx?ProductID=" + product.ProductID;
                Response.Redirect("~/UserLogin.aspx?ReturnUrl=" + returnUrl);
            }
        }

        if (!StoreContext.ShoppingCart.CheckCanAddItemToCart(product))
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + productID);
        }

        if (StoreContext.CheckoutDetails.ContainsGiftRegistry())
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx");
        }
        else
        {
            if ((DataAccessContext.OptionGroupRepository.ProductIsOptionGroup(StoreContext.Culture, productID)) || (product.IsProductKit))
            {
                Response.Redirect(UrlManager.GetProductUrl(productID, urlName));
            }
            else
            {
                if (IsPhysicalGiftCertificate(product) || !product.IsFixedPrice)
                {
                    Response.Redirect(UrlManager.GetProductUrl(productID, urlName));
                }
                else
                {
                    StoreContext.ShoppingCart.AddItem(product, product.MinQuantity);
                    Response.Redirect("ShoppingCart.aspx");
                }
            }
        }
    }
Ejemplo n.º 11
0
        public static void AddCascadeUpdateToSubsription(this Product product, ProductSubscription subscription, IUnitOfWork uow)
        {
            product.ProductSubscriptions.Add(subscription);

            EFDBEntities ef = uow.DBAccess as EFDBEntities;

            ef.Set <ProductSubscription>().AsNoTracking();
            ef.Set <ProductSubscription>().Add(subscription);
            //ef.Entry(product).CurrentValues.SetValues(product);


            //ef.Entry(subscription).State = System.Data.Entity.EntityState.Added;
            //ef.Products.Add(product);
            //ef.ProductSubscriptions.Add(subscription);
        }
Ejemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (ProductID != "0")
        {
            Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, ProductID, StoreID);

            if (product == NullProduct.Null || !product.IsEnabled)
            {
                uxProductNotAvailableMessagePanel.Visible = true;
                return;
            }

            ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);

            if (subscriptionItem.IsSubscriptionProduct())
            {
                if (StoreContext.Customer.IsNull)
                {
                    Response.Redirect("~/UserLogin.aspx?ReturnUrl=AddtoCart.aspx?ProductID=" + product.ProductID);
                }

                if (CustomerSubscription.IsContainsProductSubscriptionHigherLevel(
                        subscriptionItem.ProductSubscriptions[0].SubscriptionLevelID,
                        DataAccessContextDeluxe.CustomerSubscriptionRepository.GetCustomerSubscriptionsByCustomerID(StoreContext.Customer.CustomerID)))
                {
                    Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + product.ProductID);
                }
            }

            if (!StoreContext.ShoppingCart.CheckCanAddItemToCart(product))
            {
                Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + product.ProductID);
            }

            if (StoreContext.CheckoutDetails.ContainsGiftRegistry())
            {
                Response.Redirect("AddShoppingCartNotComplete.aspx");
            }
            else
            {
                AddItemToShoppingCart(product);
            }
        }
        else
        {
            uxProductNotExistMessagePanel.Visible = true;
        }
    }
    protected void uxUpdateItemButton_Click(object sender, EventArgs e)
    {
        string errMeg = String.Empty;

        ProductSubscription subscription = new ProductSubscription(uxProductItemDetails.ProductID);

        if (uxProductItemDetails.UpdateCartItem(subscription.IsSubscriptionProduct(), out errMeg))
        {
            PopulateShoppingCartControls();
            uxMessage.DisplayMessage("The shopping cart was updated successfully.");
        }
        else
        {
            uxAddItemButtonModalPopup.Show();
        }
    }
Ejemplo n.º 14
0
    private string AddNew()
    {
        Product product;

        product = uxGiftCertificate.Setup(uxLanguageControl.CurrentCulture);

        product = SetUpProduct(product);

        ProductSubscription subscriptionItem = uxProductSubscription.Setup(product);

        product = DataAccessContext.ProductRepository.Save(product);
        DataAccessContextDeluxe.ProductSubscriptionRepository.SaveAll(product.ProductID, subscriptionItem.ProductSubscriptions);

        uxMessage.DisplayMessage(Resources.ProductMessages.AddSuccess);

        return(product.ProductID);
    }
    protected void uxAddItemButton_Click(object sender, EventArgs e)
    {
        string errMeg = String.Empty;

        ProductSubscription subscription = new ProductSubscription(uxProductItemDetails.ProductID);

        if (uxProductItemDetails.AddItemToShoppingCart(subscription.IsSubscriptionProduct(), out errMeg))
        {
            PopulateShoppingCartControls();
            Product product = DataAccessContext.ProductRepository.GetOne(
                uxLanguageControl.CurrentCulture, uxProductItemDetails.ProductID, SelectedStoreID);
            uxMessage.DisplayMessage("The {0} was added to the shopping cart successfully.", product.Name);
        }
        else
        {
            uxAddItemButtonModalPopup.Show();
        }
    }
Ejemplo n.º 16
0
    protected void uxAddToCartButton_Click(object sender, EventArgs e)
    {
        ProductSubscription subscriptionItem = new ProductSubscription(CurrentProduct.ProductID);

        if (subscriptionItem.IsSubscriptionProduct())
        {
            if (StoreContext.Customer.IsNull)
            {
                string returnUrl = "AddtoCart.aspx?ProductID=" + CurrentProduct.ProductID;
                Response.Redirect("Login.aspx?ReturnUrl=" + returnUrl);
            }
        }

        if (!StoreContext.ShoppingCart.CheckCanAddItemToCart(CurrentProduct))
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + CurrentProduct.ProductID);
        }

        if (StoreContext.CheckoutDetails.ContainsGiftRegistry())
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx");
        }
        else
        {
            string errorMessage = String.Empty;
            if (VerifyValidInput(out errorMessage))
            {
                if (IsMatchQuantity())
                {
                    AddItemToShoppingCart();
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(errorMessage))
                {
                    uxMessage.Text       = errorMessage;
                    uxMessageDiv.Visible = true;
                }
            }
        }
    }
Ejemplo n.º 17
0
    public ProductSubscription Setup(Product product)
    {
        ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);

        if (ConvertUtilities.ToBoolean(uxIsSubscriptionProduct.SelectedValue))
        {
            subscriptionItem.ProductSubscriptions = new List <ProductSubscription>();

            ProductSubscription subscription = new ProductSubscription();
            subscription.SubscriptionLevelID = uxSubscriptionLevel.SelectedValue;
            subscription.Range     = ConvertUtilities.ToInt32(uxSubscriptionRangeText.Text);
            subscription.ProductID = product.ProductID;

            subscriptionItem.ProductSubscriptions.Add(subscription);
        }
        else
        {
            subscriptionItem.ProductSubscriptions = new List <ProductSubscription>();
        }

        return(subscriptionItem);
    }
Ejemplo n.º 18
0
    protected bool HaveProductSubscription()
    {
        Order order = DataAccessContext.OrderRepository.GetOne(CurrentOrderID);

        if (IsAdminModifiable() && order.PaymentComplete)
        {
            IList <OrderItem> orderItemList = DataAccessContext.OrderItemRepository.GetByOrderID(CurrentOrderID);

            for (int i = 0; i < orderItemList.Count; i++)
            {
                Product             product          = DataAccessContext.ProductRepository.GetOne(AdminUtilities.CurrentCulture, orderItemList[i].ProductID, new StoreRetriever().GetCurrentStoreID());
                ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);
                if (subscriptionItem.IsSubscriptionProduct())
                {
                    return(true);
                }
            }
            return(false);
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 19
0
    public void PopulateControls(Product product)
    {
        ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);

        if (subscriptionItem.IsSubscriptionProduct())
        {
            ShowProductSubscription();
        }
        else
        {
            HideProductSubscription();
        }

        if (subscriptionItem.IsSubscriptionProduct())
        {
            uxIsSubscriptionProduct.SelectedValue = "True";
            uxSubscriptionRangeText.Text          = subscriptionItem.ProductSubscriptions[0].Range.ToString();
            uxSubscriptionLevel.SelectedValue     = subscriptionItem.ProductSubscriptions[0].SubscriptionLevelID;
        }
        else
        {
            uxIsSubscriptionProduct.SelectedValue = "False";
        }
    }
Ejemplo n.º 20
0
    private bool IsProductIsValid(Product product, OrderItem orderItem, out ArrayList optionItemNameArray, out ProductKitItemValueCollection itemCollection)
    {
        //check product enabled
        optionItemNameArray = null;
        itemCollection      = ProductKitItemValueCollection.Null;

        if (!product.IsEnabled)
        {
            StoreContext.ClearCheckoutSession();
            string message = "<p class=\"ErrorHeader\">[$Product is inactive]</p>";
            ErrorMessage(message);
            return(false);
        }

        //check is product option valid
        if (!IsProductOptionValid(product, orderItem, out optionItemNameArray))
        {
            StoreContext.ClearCheckoutSession();
            string message = "<p class=\"ErrorHeader\">[$Product changed]</p>";
            ErrorMessage(message);
            return(false);
        }

        //check is category enabled
        if (!product.IsProductAvailable(StoreContext.CurrentStore.StoreID))
        {
            StoreContext.ClearCheckoutSession();
            string message = "<p class=\"ErrorHeader\">[$Product is inactive]</p>";
            ErrorMessage(message);
            return(false);
        }

        ArrayList productKitArray        = new ArrayList();
        ArrayList productKitCountArray   = new ArrayList();
        ArrayList productKitGroupIDArray = new ArrayList();

        if (product.IsProductKit)
        {
            if (!IsProductKitValid(product, orderItem, StoreContext.Culture, new StoreRetriever().GetCurrentStoreID(), out productKitArray, out productKitCountArray, out productKitGroupIDArray))
            {
                StoreContext.ClearCheckoutSession();
                string message = "<p class=\"ErrorHeader\">[$ProductKit is inactive]</p>";
                ErrorMessage(message);
                return(false);
            }

            itemCollection = GenerateProductKitItemValueCollection(product, orderItem, productKitArray, productKitCountArray, productKitGroupIDArray);
        }

        ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);

        //check customer can subscription this product
        if (subscriptionItem.IsSubscriptionProduct())
        {
            if (CustomerSubscription.IsContainsProductSubscriptionHigherLevel(
                    subscriptionItem.ProductSubscriptions[0].SubscriptionLevelID,
                    DataAccessContextDeluxe.CustomerSubscriptionRepository.GetCustomerSubscriptionsByCustomerID(StoreContext.Customer.CustomerID)))
            {
                StoreContext.ClearCheckoutSession();
                string message = "<p class=\"ErrorHeader\">[$Cannot subscription]</p>";
                ErrorMessage(message);
                return(false);
            }
        }

        return(true);
    }
Ejemplo n.º 21
0
    private void Update()
    {
        try
        {
            if (Page.IsValid)
            {
                if (uxProductInfo.ConvertToCategoryIDs().Length <= 0)
                {
                    uxMessage.DisplayError(Resources.ProductMessages.AddErrorCategoryEmpty);
                    return;
                }
                if (uxProductKit.IsProductKit)
                {
                    if (uxProductKit.GetSelectedGroupID().Length <= 0)
                    {
                        uxMessage.DisplayError(Resources.ProductMessages.AddErrorProductKitEmpty);
                        return;
                    }
                }
                if (!uxProductAttributes.VerifyInputListOption())
                {
                    DisplayErrorOption();
                    return;
                }

                string  price;
                string  retailPrice;
                string  wholeSalePrice;
                string  wholeSalePrice2;
                string  wholeSalePrice3;
                decimal giftAmount;
                if (uxProductAttributes.IsFixPrice(
                        uxGiftCertificate.IsFixedPrice, uxGiftCertificate.IsGiftCertificate, uxRecurring.IsRecurring, uxProductAttributes.IsCallForPrice))
                {
                    price           = uxProductAttributes.Price;
                    retailPrice     = uxProductAttributes.RetailPrice;
                    wholeSalePrice  = uxProductAttributes.WholeSalePrice;
                    wholeSalePrice2 = uxProductAttributes.WholeSalePrice2;
                    wholeSalePrice3 = uxProductAttributes.WholeSalePrice3;

                    giftAmount = ConvertUtilities.ToDecimal(uxGiftCertificate.GiftAmount);
                }
                else
                {
                    price           = "0";
                    retailPrice     = "0";
                    wholeSalePrice  = "0";
                    wholeSalePrice2 = "0";
                    wholeSalePrice3 = "0";
                    giftAmount      = 0m;
                }
                string  storeID = new StoreRetriever().GetCurrentStoreID();
                Product product = DataAccessContext.ProductRepository.GetOne(uxLanguageControl.CurrentCulture, CurrentID, storeID);
                product = SetUpProduct(product);
                product = uxProductImageList.Update(product);

                ProductSubscription subscriptionItem = uxProductSubscription.Setup(product);

                if (product.ProductOptionGroups.Count > 0)
                {
                    DataAccessContext.ProductKitGroupRepository.DeleteProductKitItemByProductID(product.ProductID);
                }
                product = DataAccessContext.ProductRepository.Save(product);
                DataAccessContextDeluxe.ProductSubscriptionRepository.SaveAll(product.ProductID, subscriptionItem.ProductSubscriptions);

                uxMessage.DisplayMessage(Resources.ProductMessages.UpdateSuccess);

                AdminUtilities.ClearSiteMapCache();

                PopulateControls();
            }
        }
        catch (Exception ex)
        {
            uxMessage.DisplayException(ex);
        }
    }