Ejemplo n.º 1
0
        private ContentTableHtmlView GetContentTableHtmlView(IContentModel content, Type type, AllowChildrenAttribute allowChild, long?parentId, int?langKey = null)
        {
            IEnumerable <string> additionalList = allowChild != null && allowChild.TableList != null ? allowChild.TableList : new string[] { "Title", "DisplayOrder" };
            var children          = GetAllChildContent(parentId, langKey).OrderBy(b => b.DisplayOrder).ToList().ToList();
            var tableImageColumns = allowChild != null && allowChild.TableImageList != null ? allowChild.TableImageList : new string[] { };
            var rowItems          = children.Select(b =>
            {
                var values = additionalList.Select(a => b.GetPropertyByKey(a, tableImageColumns.Contains(a))).ToList();
                return(new ContentTableRowItem(b.Id, values, b.GetType().GetRealType(), b.DisplayOrder));
            }).ToList();
            var result = new ContentTableHtmlView();

            if (allowChild != null && allowChild.DisableDelete)
            {
                result.DisableDelete = true;
            }
            result.TableHeaders = additionalList.Select(b => type.GetPropertyLabelByKey(b)).ToList();
            result.Rows         = rowItems;
            return(result);
        }
Ejemplo n.º 2
0
        public ContentTableHtmlView GetContentTableHtmlView <T>(Type type, Expression <Func <T, bool> > where) where T : IInt64Key
        {
            var children   = Read <T>(type, where, out ISave repo).ToList();
            var allowChild = type.GetObjectCustomAttribute <AllowChildrenAttribute>();

            IEnumerable <string> additionalList = allowChild != null && allowChild.TableList != null ? allowChild.TableList : new string[] { };
            var rowItems = children.Select(b =>
            {
                var values = additionalList.Select(a => b.GetPropertyByKey(a)).ToList();
                return(new ContentTableRowItem(b.Id, values, b.GetType().GetRealType()));
            }).ToList();
            var result = new ContentTableHtmlView();

            if (allowChild != null && allowChild.DisableDelete)
            {
                result.DisableDelete = true;
            }
            result.TableHeaders = additionalList.Select(b => type.GetPropertyLabelByKey(b)).ToList();
            result.Rows         = rowItems;
            return(result);
        }