Ejemplo n.º 1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="permission">权限实体</param>
        public virtual void DeletePermission(Permission permission)
        {
            if (permission == null)
                throw new ArgumentNullException("permission");

            _permissionRepository.Delete(permission);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 权限面包屑格式-排序
        /// </summary>
        /// <param name="permission">权限</param>
        /// <param name="separator">分隔符号</param>
        /// <returns>面包屑格式</returns>
        public virtual string GetFormattedDisplayOrder(Permission permission, string separator = "-")
        {
            if (permission == null)
                throw new ArgumentNullException("permission");

            string result = string.Empty;

            var alreadyProcessedPermissionIds = new List<int>() { };

            while (permission != null &&  //not null
                !permission.Deleted &&  //not deleted
                !alreadyProcessedPermissionIds.Contains(permission.Id)) //prevent circular references
            {
                if (String.IsNullOrEmpty(result))
                {
                    result = permission.DisplayOrder.ToString();
                }
                else
                {
                    result = string.Format("{0} {1} {2}", permission.DisplayOrder, separator, result);
                }

                alreadyProcessedPermissionIds.Add(permission.Id);

                permission = _permissionRepository.GetById(permission.ParentId);

            }

            return result;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="permission">权限实体</param>
        public virtual void InsertPermission(Permission permission)
        {
            if (permission == null)
                throw new ArgumentNullException("permission");

            _permissionRepository.Insert(permission);
        }