Example #1
0
        public ActionResult Create(QueryContext context)
        {
            var template = _widgetTemplateService.Get(context.WidgetTemplateID);
            var widget   = template.ToWidget(HttpContext.RequestServices);

            widget.PageID   = context.PageID;
            widget.LayoutID = context.LayoutID;
            widget.ZoneID   = context.ZoneID;
            widget.FormView = template.FormView;
            if (widget.PageID.IsNotNullAndWhiteSpace())
            {
                widget.Position = _widgetService.GetAllByPageId(HttpContext.RequestServices, context.PageID).Count(m => m.ZoneID == context.ZoneID) + 1;
            }
            else
            {
                widget.Position = _widgetService.GetByLayoutId(context.LayoutID).Count(m => m.ZoneID == context.ZoneID) + 1;
            }
            ViewBag.WidgetTemplateName = template.Title;
            ViewBag.ReturnUrl          = context.ReturnUrl;
            if (template.FormView.IsNotNullAndWhiteSpace())
            {
                return(View(template.FormView, widget));
            }
            return(View(widget));
        }
Example #2
0
        public ActionResult PageZones(QueryContext context)
        {
            var page      = Service.Get(context.PageID);
            var layout    = _layoutService.Get(page.LayoutId);
            var viewModel = new LayoutZonesViewModel
            {
                Page       = page,
                Layout     = layout,
                PageID     = context.PageID,
                LayoutID   = layout.ID,
                Zones      = _zoneService.GetZonesByPageId(context.PageID),
                Widgets    = _widgetService.GetAllByPageId(HttpContext.RequestServices, context.PageID),
                LayoutHtml = layout.Html
            };

            return(View(viewModel));
        }