Exemplo n.º 1
0
        public virtual IActionResult Edit(int id)
        {
            //return access denied page if customer has no permissions
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
            {
                return(AccessDeniedView());
            }

            //get widget zone entity and validate entity existing
            var widgetZone = _widgetZoneService.GetWidgetZoneById(id);

            if (widgetZone == null)
            {
                throw new Exception($"Widget zone by '{id}' isn't exist.");
            }

            var model = _widgetZoneModelFactory.PrepareWidgetZoneModel(new WidgetZoneModel(), widgetZone);

            //prepare widget zone ACL
            _widgetZoneModelFactory.PrepareAclModel(model, widgetZone);
            //prepare widget zone store mappings
            _widgetZoneModelFactory.PrepareStoreMappings(model, widgetZone);

            return(View("~/Plugins/Widgets.qBoSlider/Views/Admin/WidgetZone/Edit.cshtml", model));
        }
        /// <summary>
        /// Prepare model inherits slide model interface
        /// </summary>
        /// <typeparam name="TModel">Slide widget zone model interface</typeparam>
        /// <param name="widgetZoneSlide">Widget zone slide</param>
        /// <returns>Slide widget zone model</returns>
        protected virtual TModel PrepareSlideWidgetZoneModel <TModel>(WidgetZoneSlide widgetZoneSlide) where TModel : BaseNopEntityModel, ISlideWidgetZoneModel, new()
        {
            var model      = new TModel();
            var widgetZone = _widgetZoneService.GetWidgetZoneById(widgetZoneSlide.WidgetZoneId);

            model.Id         = widgetZoneSlide.Id;
            model.Name       = widgetZone.Name;
            model.SystemName = widgetZone.SystemName;
            model.Published  = widgetZone.Published;

            return(model);
        }