示例#1
0
        public Pager <KitGroup> SearchKits(string content, int take = -1, int index = 0, string terminal = null)
        {
            Terminal = terminal ?? Terminal;
            var primary   = ServiceStartup.GetPrimaryAuthorized(Terminal)?.LoginId;
            var secondary = ServiceStartup.GetSecondaryAuthorized(Terminal)?.LoginId;

            var kitLq = mongo.KitCollection.AsQueryable().Where(k => !k.IsDisabled && (k.CreatorId == primary || k.CreatorId == secondary));

            if (!string.IsNullOrEmpty(content))
            {
                content = content.ToDBC().ToLower();
                kitLq   = kitLq.Where(k => k.DisplayName.ToLower().Contains(content) || k.Pinyin.ToLower().Contains(content) || k.PinyinFull.ToLower().Contains(content));
            }
            var count    = kitLq.Count();
            var kits     = (take > 0 ? kitLq.Skip(take * index).Take(take) : kitLq).OrderBy(k => k.DisplayOrder).ToList();
            var goodsIds = kits.SelectMany(d => d.Kits).Select(g => g.GoodsId).Distinct().ToList();
            var goods    = mongo.GoodsCollection.AsQueryable().Where(g => goodsIds.Contains(g.UniqueId)).ToList();

            kits.ForEach(k => k.Kits.ForEach(gp => gp.Goods = goods.FirstOrDefault(f => f.UniqueId == gp.GoodsId) ?? new Goods {
                UniqueId = gp.GoodsId,
            }));
            return(new Pager <KitGroup>
            {
                Count = count,
                Data = kits.Select(k => new KitGroup
                {
                    UniqueId = k.UniqueId,
                    DisplayName = k.DisplayName,
                    CreatorId = k.CreatorId,
                    CreatorName = k.CreatorName,
                    DisplayOrder = k.DisplayOrder,
                    Goods = k.Kits.Select(gp => gp.Goods.ToGoodsProfileQty(string.Empty, DateTime.MaxValue.Date, gp.Qty)).ToList(),
                }).ToArray(),
            });
        }
示例#2
0
        public MenuModel NavigationForCertify(string terminal = null)
        {
            Terminal = terminal ?? Terminal;
            var primary   = ServiceStartup.GetPrimaryAuthorized(Terminal);
            var secondary = ServiceStartup.GetSecondaryAuthorized(Terminal);
            var kernel    = primary.Kernel ? true : secondary?.Kernel ?? false;

            var pId    = primary.LoginId;
            var sId    = secondary?.LoginId;
            var pMenus = mongo.UserCollection.AsQueryable().Where(u => !u.IsDisabled && u.LoginId == pId).SelectMany(u => u.Menus).ToList();
            var sMenus = mongo.UserCollection.AsQueryable().Where(u => !u.IsDisabled && u.LoginId == sId).SelectMany(u => u.Menus).ToList();

            var hospital = MongoData.Helper.GetHospital();
            // 根据不同的医院,决定
            // 菜单为登录人的交集还是并集
            var keys = new[] { "UnKnown", }.Contains(hospital) ? sId != null?pMenus.Intersect(sMenus).ToList() : pMenus : pMenus.Union(sMenus).ToList();

            var menus = mongo.MenuCollection.AsQueryable().Where(m => !m.IsDisabled).OrderBy(m => m.DisplayOrder).ToList();
            var node  = new MenuModel
            {
                Path     = "pages",
                Children = menus.Where(m => m.IsModule).Select(m => new MenuModel
                {
                    Id   = m.UniqueId,
                    Path = m.Uri,
                    Data = new Data
                    {
                        Menu = new NgMenu {
                            Expanded = false, Selected = false, Order = m.DisplayOrder, Title = m.DisplayName, Icon = m.Icon,
                        },
                    },
                    Children = menus.Where(x => x.ParentId == m.UniqueId && (kernel || keys.Any(y => y == x.UniqueId))).Select(x => new MenuModel
                    {
                        Id   = x.UniqueId,
                        Path = x.Uri,
                        Data = new Data
                        {
                            Menu = new NgMenu {
                                Expanded = false, Selected = false, Order = x.DisplayOrder, Title = x.DisplayName, Icon = x.Icon,
                            }
                        },
                    }).ToArray(),
                }).Where(m => m.Children.Any()).ToArray(),
            };

            return(node);
        }