Exemplo n.º 1
0
        public static IQueryable <Building> Peers(this Building node, bool includeSelf = false)
        {
            var ctx  = new BuildingBLL();
            var list = ctx.Filter(x => x.Rank == node.Rank || (includeSelf && x.Id == node.Id)).AsQueryable();

            return(list);
        }
Exemplo n.º 2
0
        public static IList <BalanceShortData> ToShortViewList(this IQueryable <Balance> nodes, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (nodes == null)
            {
                return(null);
            }
            var result = nodes.ToList().Select(node => node.ToShortViewData()).ToList();
            var ids    = result.Select(o => o.TargetId).ToList();

            if (nodes.Count() > 0)
            {
                Dictionary <long, string> nameDic = new Dictionary <long, string>();
                if (result[0].TargetCategory == (int)CategoryDictionary.Building)
                {
                    BuildingBLL buidingBLL = new BuildingBLL();
                    var         list       = buidingBLL.Filter(o => ids.Contains(o.Id)).Select(o => new
                    {
                        Id   = o.Id,
                        Name = o.Name
                    }).ToList();
                    foreach (var l in list)
                    {
                        nameDic.Add(l.Id, l.Name);
                    }
                }
                else if (result[0].TargetCategory == (int)CategoryDictionary.Organization)
                {
                    OrganizationBLL orgBLL = new OrganizationBLL();
                    var             list   = orgBLL.Filter(o => ids.Contains(o.Id)).Select(o => new
                    {
                        Id   = o.Id,
                        Name = o.Name
                    }).ToList();
                    foreach (var l in list)
                    {
                        nameDic.Add(l.Id, l.Name);
                    }
                }
                foreach (var r in result)
                {
                    r.Name = nameDic[r.TargetId];
                }
            }
            return(result);
        }