public static 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); }
public static ContentTableHtmlView GetContentTableHtmlView(long?parentId) { var content = ContentManager.GetContent(parentId); Type type = content != null?content.GetType().GetRealType() : BasicContentType; var allowChild = type.GetObjectCustomAttribute <AllowChildrenAttribute>(); IEnumerable <string> additionalList = allowChild != null && allowChild.TableList != null ? allowChild.TableList : new string[] { "Title", "DisplayOrder" }; var children = GetAllChildContent(parentId).OrderBy(b => b.DisplayOrder).ToList().ToList(); var rowItems = children.Select(b => { var values = additionalList.Select(a => b.GetPropertyByKey(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); }
public static ContentTableHtmlView GetContentTableHtmlView(IEnumerable <SDHCUser> users) { var children = users == null?Enumerable.Empty <SDHCUser>() : users; var allowChild = BaseUser.GetObjectCustomAttribute <AllowChildrenAttribute>(); IEnumerable <string> additionalList = allowChild != null && allowChild.TableList != null ? allowChild.TableList : new string[] { }; long id = 0; var rowItems = children.Select(b => { id++; var values = additionalList.Select(a => b.GetPropertyByKey(a)).ToList(); return(new ContentTableRowItem(id, values, b.GetType().GetRealType(), 0, b.Id)); }).ToList(); var result = new ContentTableHtmlView(); if (allowChild != null && allowChild.DisableDelete) { result.DisableDelete = true; } result.TableHeaders = additionalList.Select(b => BaseUser.GetPropertyLabelByKey(b)).ToList(); result.Rows = rowItems; return(result); }