public ActionResult AddWidget(int hostId, string widgetType, string zone, string returnUrl) { if (!IsAuthorizedToManageWidgets()) { return(new HttpUnauthorizedResult()); } var widgetPart = _services.ContentManager.New <WidgetPart>(widgetType); if (widgetPart == null) { return(HttpNotFound()); } try { var widgetPosition = _widgetManager.GetWidgets(hostId).Count(widget => widget.Zone == widgetPart.Zone) + 1; widgetPart.Position = widgetPosition.ToString(CultureInfo.InvariantCulture); widgetPart.Zone = zone; widgetPart.AvailableLayers = _widgetsService.GetLayers().ToList(); widgetPart.LayerPart = _widgetManager.GetContentLayer(); var model = _services.ContentManager.BuildEditor(widgetPart).HostId(hostId); return(View(model)); } catch (Exception exception) { Logger.Error(T("Creating widget failed: {0}", exception.Message).Text); _services.Notifier.Error(T("Creating widget failed: {0}", exception.Message)); return(this.RedirectLocal(returnUrl, () => RedirectToAction("Edit", "Admin", new { area = "Contents" }))); } }
public int UpdateFrom4() { // Used this method because it was the operation I needed. // Create the ContentWidgets layer if it doesn't already exist _widgetManager.GetContentLayer(); return(5); }