Exemplo n.º 1
0
        public IEnumerable <Widget> GetWidgets(int parentId, bool?isTree)
        {
            var widgets = (isTree.HasValue && isTree.Value) || parentId > -1
                ? _widgetRepository.FindBy(w => w.ParentId == parentId && w.Id > 0).ToList()
                : _widgetRepository.FindBy(w => w.Id > 0).ToList();

            foreach (var widget in widgets)
            {
                if (widget.ArticleId.HasValue)
                {
                    widget.Article = _articleRepository.GetSingle(widget.ArticleId.Value);
                }

                widget.WidgetSize   = _widgetSizeRepository.GetSingle(widget.WidgetSizeId);
                widget.WidgetClass  = _widgetClassRepository.GetSingle(widget.WidgetClassId);
                widget.ChildWidgets = GetWidgets(widget.Id, isTree);
            }

            return(widgets);
        }