Пример #1
0
        public void AddPrivilegeToRole(List <RolePrivilege> privileges, PrivilegeAction pAction)
        {
            var itemToUpdate = privileges.FirstOrDefault(rp => rp.PrivilegeId == pAction.PrivilegeId);

            if (itemToUpdate != null)
            {
                itemToUpdate.Depth = GetDepthFromLevel(pAction.Level);
            }
            else
            {
                itemToUpdate = new RolePrivilege
                {
                    PrivilegeId = pAction.PrivilegeId,
                    Depth       = GetDepthFromLevel(pAction.Level)
                };

                privileges.Add(itemToUpdate);
            }
        }
Пример #2
0
        public void AddPrivilegeToRole(List<RolePrivilege> privileges, PrivilegeAction pAction)
        {
            var itemToUpdate = privileges.FirstOrDefault(rp => rp.PrivilegeId == pAction.PrivilegeId);

            if (itemToUpdate != null)
            {
                itemToUpdate.Depth = GetDepthFromLevel(pAction.Level);
            }
            else
            {
                itemToUpdate = new RolePrivilege
                                   {
                                       PrivilegeId = pAction.PrivilegeId,
                                       Depth = GetDepthFromLevel(pAction.Level)
                                   };

                privileges.Add(itemToUpdate);
            }
        }