Class GroupDeleting
- Namespace
- Dynamicweb.Ecommerce.Products
- Assembly
- Dynamicweb.Ecommerce.dll
Helper class to properly delete group with access rights checks and from all places: pages, shops, other groups and products relations etc.
public class GroupDeleting
- Inheritance
-
GroupDeleting
- Inherited Members
Examples
using Dynamicweb.Ecommerce.Products;
using Dynamicweb.Ecommerce.Shops;
using Dynamicweb.Ecommerce.UserPermissions;
namespace Dynamicweb.Ecommerce.Examples.Products
{
class ProductGroupDeleteHandlerSample
{
public bool Run(string shopId)
{
Shop shop = Ecommerce.Services.Shops.GetShop(shopId);
if (!shop.get_Granted(UserPermissionRights.Delete))
{
return false;
}
//Delete groups
bool allGroupsDeleted = true;
foreach (Group group in shop.GetTopLevelGroups(Services.Languages.GetDefaultLanguageId()))
{
allGroupsDeleted = GroupDeleting.Run(group.Id, shop.UsageType) && allGroupsDeleted;
}
//Delete shop
if (allGroupsDeleted)
{
Ecommerce.Services.Shops.Delete(shop.Id);
Dynamicweb.Ecommerce.Common.Application.KillShops();
return true;
}
return false;
}
}
}
Methods
Run(string)
Deletes the product group and its subgroups.
public static bool Run(string groupId)
Parameters
groupIdstring- The ID of the group to delete.
Returns
- bool
Trueif the group and all its subgroups were successfully deleted, otherwiseFalse
Run(string, ShopType)
Deletes the product group and its subgroups.
public static bool Run(string groupId, ShopType usageType)
Parameters
Returns
- bool
Trueif the group and all its subgroups were successfully deleted, otherwiseFalse