/// <summary>
        /// Deletes all sample SKUs created by <see cref="CreateSampleSKUs"/>.
        /// </summary>
        public ActionResult DeleteSampleSKUs()
        {
            var sampleSKUs = SKUInfoProvider.GetSKUs(SiteContext.CurrentSiteID).WhereEquals("SKUShortDescription", "LearningKit_SampleData");

            foreach (var SKU in sampleSKUs)
            {
                SKUInfoProvider.DeleteSKUInfo(SKU);
            }

            return(RedirectToAction("Index", "Home"));
        }
    /// <summary>
    /// Deletes items from given data set.
    /// </summary>
    /// <param name="options"></param>
    private void DeleteOptions(DataSet options)
    {
        if (DataHelper.DataSourceIsEmpty(options))
        {
            return;
        }

        // Delete text option
        foreach (DataRow option in options.Tables[0].Rows)
        {
            SKUInfoProvider.DeleteSKUInfo(ValidationHelper.GetInteger(option["SKUID"], 0));
        }
    }
Ejemplo n.º 3
0
    private void gridData_OnAction(string actionName, object actionArgument)
    {
        if (string.IsNullOrEmpty(actionName))
        {
            return;
        }

        var argument = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName.ToLowerInvariant())
        {
        case "edit":
        {
            string url   = ProductUIHelper.GetProductEditUrl();
            string query = DocumentListingDisplayed ? "?sectionId=" + NodeID + "&nodeId=" + argument + "&culture=" + CultureCode : "?productid=" + argument;

            url = URLHelper.AppendQuery(url, query);

            URLHelper.Redirect(UrlResolver.ResolveUrl(url));
        }
        break;

        case "delete":
            if (DocumentListingDisplayed)
            {
                var url = "Product_Section.aspx?action=delete&nodeId=" + argument;
                URLHelper.Redirect(UrlResolver.ResolveUrl(URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url))));
            }
            else
            {
                SKUInfo skuObj = SKUInfoProvider.GetSKUInfo(argument);

                // Check module permissions
                CheckModifyPermission(skuObj);

                // Check dependencies
                if (SKUInfoProvider.CheckDependencies(argument))
                {
                    // Show error message
                    ShowError(EcommerceUIHelper.GetDependencyMessage(skuObj));

                    return;
                }

                SKUInfoProvider.DeleteSKUInfo(skuObj);
            }

            break;
        }
    }
Ejemplo n.º 4
0
    private void gridData_OnAction(string actionName, object actionArgument)
    {
        int argument = ValidationHelper.GetInteger(actionArgument, 0);

        actionName = actionName.ToLowerCSafe();

        switch (actionName)
        {
        case "edit":
        {
            string url   = ProductUIHelper.GetProductEditUrl();
            string query = DocumentListingDisplayed ? "?sectionId=" + NodeID + "&nodeId=" + argument + "&culture=" + CultureCode : "?productid=" + argument;

            url = URLHelper.AppendQuery(url, query);

            URLHelper.Redirect(url);
        }
        break;

        case "delete":
            if (DocumentListingDisplayed)
            {
                URLHelper.Redirect("Product_Section.aspx?action=delete&nodeId=" + argument);
            }
            else
            {
                SKUInfo skuObj = SKUInfoProvider.GetSKUInfo(argument);

                // Check module permissions
                CheckModifyPermission(skuObj);

                // Check dependencies
                if (SKUInfoProvider.CheckDependencies(argument))
                {
                    // Show error message
                    ShowError(ECommerceHelper.GetDependencyMessage(skuObj));

                    return;
                }

                SKUInfoProvider.DeleteSKUInfo(skuObj);
            }

            break;
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Destroys items from given data set.
    /// </summary>
    /// <param name="options">Options to be destroyed.</param>
    private void DestroyOptions(DataSet options)
    {
        if (DataHelper.DataSourceIsEmpty(options))
        {
            return;
        }

        // Delete without ensuring the version
        using (new CMSActionContext {
            CreateVersion = false
        })
        {
            foreach (DataRow option in options.Tables[0].Rows)
            {
                SKUInfoProvider.DeleteSKUInfo(ValidationHelper.GetInteger(option["SKUID"], 0));
            }
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Deletes or disables variant. Returns true when variant was deleted, false when disabled.
    /// </summary>
    /// <param name="variantInfo"> Variant of product</param>
    private bool DeleteVariant(SKUInfo variantInfo)
    {
        // Check variant dependencies and delete it if possible, otherwise disable it
        if (variantInfo.Generalized.CheckDependencies())
        {
            // Disable variant
            variantInfo.SKUEnabled = false;
            SKUInfoProvider.SetSKUInfo(variantInfo);

            return(false);
        }

        AddLog(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(variantInfo.SKUName)) + GetString("com.variant.isbeingdeleted"));

        // Delete variant product
        SKUInfoProvider.DeleteSKUInfo(variantInfo);

        return(true);
    }
Ejemplo n.º 7
0
    private void grid_OnAction(string actionName, object actionArgument)
    {
        int skuId = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName.ToLowerCSafe())
        {
        case "edit":
            URLHelper.Redirect("~/CMSModules/Ecommerce/Pages/Tools/Products/Product_Edit_Frameset.aspx?categoryid=" + categoryId + "&productid=" + skuId + "&siteId=" + categoryObj.CategorySiteID);
            break;

        case "delete":
            // Check permissions
            CheckModifyPermission();

            // Check dependencies
            if (SKUInfoProvider.CheckDependencies(skuId))
            {
                // Show error message
                ShowError(GetString("Ecommerce.DeleteDisabled"));

                return;
            }

            SKUInfoProvider.DeleteSKUInfo(skuId);
            grid.ReloadData();

            break;

        case "moveup":
            // Check permissions
            CheckModifyPermission();

            SKUInfoProvider.MoveSKUOptionUp(skuId);
            break;

        case "movedown":
            // Check permissions
            CheckModifyPermission();

            SKUInfoProvider.MoveSKUOptionDown(skuId);
            break;
        }
    }
Ejemplo n.º 8
0
    void gridData_OnAction(string actionName, object actionArgument)
    {
        switch (actionName.ToLower())
        {
        case "edit":
            URLHelper.Redirect("Product_Edit_Frameset.aspx?productid=" + ValidationHelper.GetInteger(actionArgument, 0) + "&siteId=" + SelectSite.SiteID);
            break;

        case "delete":
            int     skuId  = ValidationHelper.GetInteger(actionArgument, 0);
            SKUInfo skuObj = SKUInfoProvider.GetSKUInfo(skuId);

            // Check module permissions
            if (!ECommerceContext.IsUserAuthorizedToModifySKU(skuObj))
            {
                if (skuObj.IsGlobal)
                {
                    RedirectToAccessDenied("CMS.Ecommerce", "EcommerceGlobalModify");
                }
                else
                {
                    RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyProducts");
                }
            }

            // Check dependencies
            if (SKUInfoProvider.CheckDependencies(skuId))
            {
                lblError.Visible = true;
                lblError.Text    = GetString("Ecommerce.DeleteDisabled");
                return;
            }

            SKUInfoProvider.DeleteSKUInfo(skuObj);

            break;
        }
    }
    private void grid_OnAction(string actionName, object actionArgument)
    {
        if (string.IsNullOrEmpty(actionName))
        {
            return;
        }

        int skuId = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName.ToLowerInvariant())
        {
        case "edit":
            // Show product tabs for type Products, otherwise show only general tab
        {
            var url = UIContextHelper.GetElementUrl(ModuleName.ECOMMERCE, "ProductOptions.Options.General");
            url = URLHelper.AddParameterToUrl(url, "displaytitle", "false");
            url = URLHelper.AddParameterToUrl(url, "productId", skuId.ToString());
            url = URLHelper.AddParameterToUrl(url, "categoryid", categoryId.ToString());
            url = URLHelper.AddParameterToUrl(url, "siteId", categoryObj.CategorySiteID.ToString());
            url = URLHelper.AddParameterToUrl(url, "objectid", skuId.ToString());
            // To be able to hide tax class tab for attribute and text option
            url = URLHelper.AddParameterToUrl(url, "parentobjectid", categoryId.ToString());

            // Add parent product id
            if (parentProductId > 0)
            {
                url += "&parentProductId=" + parentProductId;
            }

            if (QueryHelper.GetBoolean("isindialog", false))
            {
                url = URLHelper.AddParameterToUrl(url, "isindialog", "1");
                url = ApplicationUrlHelper.AppendDialogHash(url);
            }

            URLHelper.Redirect(url);
        }
        break;

        case "delete":
            // Check permissions
            CheckModifyPermission();

            // Check dependencies
            if (SKUInfoProvider.CheckDependencies(skuId))
            {
                // Show error message
                ShowError(EcommerceUIHelper.GetDependencyMessage(SKUInfoProvider.GetSKUInfo(skuId)));

                return;
            }

            // Check if same variant is defined by this option
            DataSet variants = VariantOptionInfoProvider.GetVariantOptions()
                               .TopN(1)
                               .Columns("VariantSKUID")
                               .WhereEquals("OptionSKUID", skuId);

            if (!DataHelper.DataSourceIsEmpty(variants))
            {
                // Option is used in some variant
                ShowError(GetString("com.option.usedinvariant"));

                return;
            }

            SKUInfoProvider.DeleteSKUInfo(skuId);
            ugOptions.ReloadData();

            break;
        }
    }
    private void gridData_OnAction(string actionName, object actionArgument)
    {
        int argument = ValidationHelper.GetInteger(actionArgument, 0);

        actionName = actionName.ToLowerCSafe();

        switch (actionName)
        {
        case "edit":
            string url = null;

            if (NodeID > 0)
            {
                url = "Product_Edit_Frameset.aspx?sectionId=" + NodeID + "&nodeId=" + argument + "&culture=" + CultureCode;
            }
            else
            {
                url = "Product_Edit_Frameset.aspx?productid=" + argument;
            }

            URLHelper.Redirect(url);

            break;

        case "delete":
            if (NodeID > 0)
            {
                URLHelper.Redirect("Product_Section.aspx?action=delete&nodeId=" + argument);
            }
            else
            {
                SKUInfo skuObj = SKUInfoProvider.GetSKUInfo(argument);

                // Check module permissions
                if (!ECommerceContext.IsUserAuthorizedToModifySKU(skuObj))
                {
                    if (skuObj.IsGlobal)
                    {
                        RedirectToAccessDenied("CMS.Ecommerce", "EcommerceGlobalModify");
                    }
                    else
                    {
                        RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyProducts");
                    }
                }

                // Check dependencies
                if (SKUInfoProvider.CheckDependencies(argument))
                {
                    // Show error message
                    ShowError(GetString("Ecommerce.DeleteDisabled"));

                    return;
                }

                SKUInfoProvider.DeleteSKUInfo(skuObj);
            }

            break;
        }
    }
Ejemplo n.º 11
0
    private void grid_OnAction(string actionName, object actionArgument)
    {
        int skuId = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName.ToLowerCSafe())
        {
        case "edit":
            // Show product tabs for type Products, otherwise show only general tab
        {
            string url = (categoryObj.CategoryType == OptionCategoryTypeEnum.Products) ?
                         UIContextHelper.GetElementUrl("CMS.ECommerce", "ProductOptions.Options.Edit") :
                         "~/CMSModules/Ecommerce/Pages/Tools/Products/Product_Edit_General.aspx";

            url = URLHelper.AddParameterToUrl(url, "displaytitle", "false");
            url = URLHelper.AddParameterToUrl(url, "productId", skuId.ToString());
            url = URLHelper.AddParameterToUrl(url, "categoryid", categoryId.ToString());
            url = URLHelper.AddParameterToUrl(url, "siteId", categoryObj.CategorySiteID.ToString());
            url = URLHelper.AddParameterToUrl(url, "objectid", categoryId.ToString());
            url = URLHelper.AddParameterToUrl(url, "dialog", QueryHelper.GetString("dialog", "0"));

            // Add parent product id
            if (parentProductId > 0)
            {
                url += "&parentProductId=" + parentProductId;
            }

            URLHelper.Redirect(url);
        }
        break;

        case "delete":
            // Check permissions
            CheckModifyPermission();

            // Check dependencies
            if (SKUInfoProvider.CheckDependencies(skuId))
            {
                // Show error message
                ShowError(GetString("Ecommerce.DeleteDisabled"));

                return;
            }

            // Check if same variant is defined by this option
            DataSet variants = VariantOptionInfoProvider.GetVariantOptions()
                               .TopN(1)
                               .Columns("VariantSKUID")
                               .WhereEquals("OptionSKUID", skuId);

            if (!DataHelper.DataSourceIsEmpty(variants))
            {
                // Option is used in some variant
                ShowError(GetString("com.option.usedinvariant"));

                return;
            }

            SKUInfoProvider.DeleteSKUInfo(skuId);
            ugOptions.ReloadData();

            break;

        case "moveup":
            // Check permissions
            CheckModifyPermission();

            SKUInfoProvider.MoveSKUOptionUp(skuId);
            break;

        case "movedown":
            // Check permissions
            CheckModifyPermission();

            SKUInfoProvider.MoveSKUOptionDown(skuId);
            break;
        }
    }