/// <summary>
        /// Prepare paged widget list model
        /// </summary>
        /// <param name="searchModel">Widget search model</param>
        /// <returns>Widget list model</returns>
        public override WidgetListModel PrepareWidgetListModel(WidgetSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //exclude Avalara tax provider from the widget list
            var widgets = _widgetService.LoadAllWidgets()
                          .Where(widget => !widget.PluginDescriptor.SystemName.Equals(AvalaraTaxDefaults.SystemName));

            //prepare grid model
            var model = new WidgetListModel
            {
                Data = widgets.PaginationByRequestModel(searchModel).Select(widget =>
                {
                    //fill in model values from the entity
                    var widgetMethodModel = widget.ToPluginModel <WidgetModel>();

                    //fill in additional values (not existing in the entity)
                    widgetMethodModel.IsActive         = _widgetService.IsWidgetActive(widget);
                    widgetMethodModel.ConfigurationUrl = widget.GetConfigurationPageUrl();

                    return(widgetMethodModel);
                }),
                Total = widgets.Count()
            };

            return(model);
        }
예제 #2
0
        /// <summary>
        /// Prepare paged widget list model
        /// </summary>
        /// <param name="searchModel">Widget search model</param>
        /// <returns>Widget list model</returns>
        public virtual async Task <WidgetListModel> PrepareWidgetListModelAsync(WidgetSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get widgets
            var widgets = (await _widgetPluginManager.LoadAllPluginsAsync())
                          .Where(widget => !widget.HideInWidgetList).ToList()
                          .ToPagedList(searchModel);

            //prepare grid model
            var model = new WidgetListModel().PrepareToGrid(searchModel, widgets, () =>
            {
                return(widgets.Select(widget =>
                {
                    //fill in model values from the entity
                    var widgetMethodModel = widget.ToPluginModel <WidgetModel>();

                    //fill in additional values (not existing in the entity)
                    widgetMethodModel.IsActive = _widgetPluginManager.IsPluginActive(widget);
                    widgetMethodModel.ConfigurationUrl = widget.GetConfigurationPageUrl();

                    return widgetMethodModel;
                }));
            });

            return(model);
        }
예제 #3
0
        /// <summary>
        /// Prepare paged widget list model
        /// </summary>
        /// <param name="searchModel">Widget search model</param>
        /// <returns>Widget list model</returns>
        public virtual WidgetListModel PrepareWidgetListModel(WidgetSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get widgets
            var widgets = _widgetService.LoadAllWidgets();

            //prepare grid model
            var model = new WidgetListModel
            {
                Data = widgets.PaginationByRequestModel(searchModel).Select(widget =>
                {
                    //fill in model values from the entity
                    var widgetMethodModel = widget.ToModel();

                    //fill in additional values (not existing in the entity)
                    widgetMethodModel.IsActive         = widget.IsWidgetActive(_widgetSettings);
                    widgetMethodModel.ConfigurationUrl = widget.GetConfigurationPageUrl();

                    return(widgetMethodModel);
                }),
                Total = widgets.Count
            };

            return(model);
        }
예제 #4
0
        public IActionResult List()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
            {
                return(AccessDeniedView());
            }
            var widgets = _widgetService
                          .GetAll()
                          .Where(w => w.StoreId == 0 || w.StoreId == _storeScope)
                          .OrderBy(w => w.Order)
                          .Select(w => new WidgetModel
            {
                Id         = w.Id,
                IsActive   = w.IsActive,
                Content    = w.Content,
                Order      = w.Order,
                WidgetZone = $"{GetWidgetZoneName(w.WidgetZone)} ({w.WidgetZone})"
            })
                          .ToList();
            var model = new WidgetListModel
            {
                Data  = widgets,
                Total = widgets.Count
            };

            return(Json(model));
        }
예제 #5
0
        public ActionResult List()
        {
            var model = new WidgetListModel();

            //widget plugins
            model.AvailableWidgetPlugins = _widgetService.LoadAllWidgetPlugins()
                                           .Select(x => new WidgetPluginModel()
            {
                SystemName   = x.PluginDescriptor.SystemName,
                FriendlyName = x.PluginDescriptor.FriendlyName
            })
                                           .ToList();
            //widgets
            foreach (var widget in _widgetService.GetAllWidgets().OrderBy(w => w.WidgetZoneId).ThenBy(w => w.DisplayOrder))
            {
                var widgetModel = PrepareWidgetModel(widget);
                if (widgetModel != null)
                {
                    model.AvailableWidgets.Add(widgetModel);
                }
            }

            return(View(model));

            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
            //    return AccessDeniedView();

            //var widgetsModel = new List<WidgetModel>();
            //var widgets = _widgetService.LoadAllWidgets();
            //foreach (var widget in widgets)
            //{
            //    var tmp1 = widget.ToModel();
            //    tmp1.IsActive = widget.IsWidgetActive(_widgetSettings);
            //    widgetsModel.Add(tmp1);
            //}
            //var gridModel = new GridModel<WidgetModel>
            //{
            //    Data = widgetsModel,
            //    Total = widgetsModel.Count()
            //};
            //return View(gridModel);
        }
예제 #6
0
        public ActionResult List()
        {
            var model = new WidgetListModel();

            //widget plugins
            model.AvailableWidgetPlugins = _widgetService.LoadAllWidgetPlugins()
                                           .Select(x => new WidgetPluginModel()
            {
                SystemName   = x.PluginDescriptor.SystemName,
                FriendlyName = x.PluginDescriptor.FriendlyName
            })
                                           .ToList();
            //widgets
            foreach (var widget in _widgetService.GetAllWidgets().OrderBy(w => w.WidgetZoneId).ThenBy(w => w.DisplayOrder))
            {
                var widgetModel = PrepareWidgetModel(widget);
                if (widgetModel != null)
                {
                    model.AvailableWidgets.Add(widgetModel);
                }
            }

            return(View(model));
        }