Ejemplo n.º 1
0
        public OpResult RemoveRole(int[] ids)
        {
            var list = ProductRoleRepository.GetQuery(o => ids.Contains(o.Id)).Include(o => o.ProductRoleDatas).ToList();

            ProductRoleDataRepository.RemoveRange(list.SelectMany(o => o.ProductRoleDatas).ToList(), false);
            ProductRoleRepository.RemoveRange(list);
            return(OpResult.Success());
        }
Ejemplo n.º 2
0
        public IEnumerable <dynamic> RoleList(string verId)
        {
            var queryRole = ProductRoleRepository.GetQuery(o => o.RoleVerId == verId);
            var queryUser = UserRepository.GetQuery();
            var q         = from x in queryRole
                            select new {
                x.Id,
                x.RoleId,
                x.Title,
                x.CreateDT,
                x.CreateUID,
                Creater = queryUser.Where(o => o.UserId == x.CreateUID).Select(o => o.FullName).FirstOrDefault(),
            };

            return(q.ToList());
        }
Ejemplo n.º 3
0
        public List <Models.ProductRoleMenuModel> FindMenuList(int productId, int roleId, string verId, bool isdetail)
        {
            lock (_objlock)
            {
                var queryMenu     = ProductMenuLimitRepository.GetQuery();
                var queryRoleVer  = ProductRoleVerRepository.GetQuery(o => o.RoleVerId == verId);
                var queryRole     = ProductRoleRepository.GetQuery(o => o.RoleId == roleId);
                var queryRoleData = ProductRoleDataRepository.GetQuery();
                var ver           = Get(verId);
                var ms            = new List <Models.ProductRoleMenuModel>();
                if (ver != null && !ver.ModuleId.IsNullOrEmpty())
                {
                    queryMenu = queryMenu.Where(o => o.ModuleId == ver.ModuleId);
                    var q = from x in queryRoleData
                            join z in queryRole on x.RoleDataId equals z.Id
                            join y in queryMenu on x.MenuId equals y.MenuId
                            where z.RoleVerId == verId && queryRoleVer.Any(o => o.ModuleId == y.ModuleId)
                            orderby x.SortOrder
                            select new Models.ProductRoleMenuModel()
                    {
                        Id           = y.MenuId,
                        MenuId       = y.MenuId,
                        PMenuId      = y.PMenuId,
                        Title        = y.Title,
                        LimitSelects = z.Limitids,
                        ParentId     = x.HasSelected ? 1 : 0
                    };
                    ms = q.ToList();
                    var limits = queryMenu.Where(o => o.Type == 3).ToList();
                    ms.Each(o =>
                    {
                        o.Limitids      = string.Join(",", limits.Where(i => i.PMenuId == o.MenuId).Select(i => i.Title + ":" + i.MenuId));
                        o.MenuIdSelects = string.Join(",", ms.Where(i => i.ParentId == 1).Select(i => i.MenuId));
                    });
                    ms.Each(o =>
                    {
                        o.ParentId = 0;
                    });
                }
                if (!ms.Any())
                {
                    var modelVer = ProductModelVerService.GetOfficialLast(productId);
                    if (modelVer != null && ver != null)
                    {
                        var role = ver.ProductRoles.FirstOrDefault(o => o.RoleId == roleId);
                        if (!role.ProductRoleDatas.Any())
                        {
                            role.ProductRoleDatas.AddRange(modelVer.ProductMenuLimits.Where(o => o.Type != 3).Select(o => new ProductRoleData()
                            {
                                PMenuId   = o.PMenuId,
                                MenuId    = o.MenuId,
                                SortOrder = o.SortOrder,
                            }));
                            ver.ModuleId = modelVer.ModuleId;
                            ProductRoleVerRepository.SaveChanges();
                        }

                        ms.AddRange(modelVer.ProductMenuLimits.Where(o => o.Type != 3).OrderBy(o => o.SortOrder).Select(o => new Models.ProductRoleMenuModel()
                        {
                            Id       = o.MenuId,
                            MenuId   = o.MenuId,
                            PMenuId  = o.PMenuId,
                            Title    = o.Title,
                            Limitids = string.Join(",", modelVer.ProductMenuLimits.Where(i => i.PMenuId == o.MenuId && i.Type == 3).Select(i => i.Title + ":" + i.MenuId))
                        }));
                    }
                }
                var list = new List <Models.ProductRoleMenuModel>();
                foreach (var menu in ms.Where(o => o.PMenuId <= 0))
                {
                    SetChilds(menu, ms);
                    menu.Index = list.Count;
                    list.Add(menu);
                }
                return(list);
            }
        }