private void DeleteWidgets(WidgetsContainerPart part) { var contentItem = part.ContentItem; var widgets = _widgetManager.GetWidgets(contentItem.Id, false); foreach (var w in widgets) { _contentManager.Remove(w.ContentItem); } }
/// <summary> /// Reset the culture of all widgets in the cloned content if this is a translation /// </summary> /// <param name="context"></param> /// <param name="part"></param> private void ResetWidgetsLocalization(CloneContentContext context, WidgetsContainerPart part) { var baseLocPart = part.ContentItem.As <LocalizationPart>(); if (baseLocPart != null) { var routeData = _wca.GetContext().HttpContext.Request.RequestContext.RouteData.Values; object action, area; if (routeData.TryGetValue("action", out action) && routeData.TryGetValue("area", out area) && action.ToString().ToUpperInvariant() == "TRANSLATE" && area.ToString().ToUpperInvariant() == "ORCHARD.LOCALIZATION") { var widgetsLocParts = _widgetManager .GetWidgets(context.CloneContentItem.Id, context.CloneContentItem.IsPublished()) .Select(wi => wi.ContentItem.As <LocalizationPart>()) .Where(pa => pa != null); foreach (var wLocPart in widgetsLocParts) { wLocPart.Culture = null; } } } }