Esempio n. 1
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));
        }
Esempio n. 2
0
 public IList <string> GetWidgetZones()
 {
     return(_widgetService.GetAll()
            .Where(w => w.IsActive && (w.StoreId == 0 || w.StoreId == _storeScope))
            .Select(w => w.WidgetZone)
            .Distinct()
            .ToList());
 }
Esempio n. 3
0
        public IViewComponentResult Invoke(string widgetZone, object additionalData)
        {
            var widgetContents = _widgetService.GetAll()
                                 .Where(w => w.IsActive &&
                                        string.Equals(w.WidgetZone, widgetZone, StringComparison.OrdinalIgnoreCase) &&
                                        (w.StoreId == 0 || w.StoreId == _storeScope))
                                 .OrderBy(w => w.Order)
                                 .Select(w => w.Content);

            return(View("~/Plugins/Widgets.JustHtml/Views/PublicInfo.cshtml", string.Join(_settings.WidgetSeparator, widgetContents)));
        }