示例#1
0
        public IActionResult SaveWidget(WidgetModel widgetModel)
        {
            var widgets = _pluginAccountant.GetAvailableWidgets();

            if (!widgets.Any(x => x.PluginSystemName == widgetModel.PluginSystemName &&
                             x.WidgetSystemName == widgetModel.WidgetSystemName))
            {
                return(R.Fail.With("error", T("Widget not found")).Result);
            }

            if (!ApplicationEngine.ActiveTheme.WidgetZones.ContainsKey(widgetModel.ZoneName))
            {
                return(R.Fail.With("error", T("Zone not found")).Result);
            }

            _pluginSettings.AddWidget(widgetModel.WidgetSystemName, widgetModel.PluginSystemName, widgetModel.ZoneName);
            return(R.Success.Result);
        }