public ResultModel SaveWidgets(ICollection <Widget> widgets)
 {
     try
     {
         if (widgets == null)
         {
             return(new ResultModel(false, "Null collection"));
         }
         var webConfiguration = WebConfigurationManager.OpenWebConfiguration("~");
         PageRenderHelperConfigurationSection widgetSection = (PageRenderHelperConfigurationSection)webConfiguration.GetSection("pageRenderHelper");
         widgetSection.EmbeddableViews.Clear();
         foreach (var widget in widgets.OrderBy(x => x.Pattern))
         {
             widgetSection.EmbeddableViews.Add(new EmbeddableView()
             {
                 Pattern = widget.Pattern,
                 Path    = widget.ViewPath
             });
         }
         webConfiguration.Save();
         return(ResultModel.Success);
     }
     catch (Exception e)
     {
         _logService.LogError(e);
         return(new ResultModel(e));
     }
 }
        public ICollection <Widget> GetWidgets()
        {
            var widgets = new List <Widget>();
            PageRenderHelperConfigurationSection widgetSection = (PageRenderHelperConfigurationSection)ConfigurationManager.GetSection("pageRenderHelper");

            foreach (EmbeddableView rec in widgetSection.EmbeddableViews)
            {
                if (string.IsNullOrEmpty(rec.Pattern))
                {
                    continue;
                }
                widgets.Add(new Widget(rec.Pattern, rec.Path));
            }
            return(widgets);
        }