/// <summary>
        /// Determines whether this instance [can perform action] the specified action.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <returns></returns>
        public bool EvaluatePermission(int action)
        {
            if (User?.Roles == null || User.Roles.Count == 0)
            {
                return(false);
            }

            //if it's an admin user we don't need to evaluate the permissions
            if (User.Roles.Any(c => c.Value.IsAdminRole))
            {
                return(true);
            }

            var permissionList = permissionStore.GetPermissions(resourceId);

            foreach (var userRole in User.Roles)
            {
                if (!permissionList.TryGetValue(userRole.Value.RoleNumber, out IPermissionItem permission))
                {
                    continue;
                }
                var perm = (permission.PermValue & action) == action;
                if (perm)
                {
                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        ///     Gets all permissions for a given grain/secitem.
        /// </summary>
        public async Task <IEnumerable <Permission> > GetPermissions(string grain          = null, string securableItem = null,
                                                                     string permissionName = null, bool includeDeleted  = false)
        {
            var permissions = await _permissionStore.GetPermissions(grain, securableItem, permissionName);

            return(permissions.Where(p => !p.IsDeleted || includeDeleted));
        }
        /// <summary>
        /// Determines whether this instance [can perform action] the specified action.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <returns></returns>
        public bool EvaluatePermission(int action)
        {
            if (User?.Roles == null || User.Roles.Count == 0)
            {
                return(false);
            }

            //if it's an admin user we don't need to evaluate the permissions
            if (User.Roles.ContainsKey(adminRoleName))
            {
                return(true);
            }

            var permissionList = permissionStore.GetPermissions(resourceId);

            for (var i = 0; i < permissionList.Count; i++)
            {
                var permission = permissionList[i];
                if (!userRoles.ContainsKey(permission.RoleNumber))
                {
                    continue;
                }

                var perm = (permission.PermValue & action) == action;
                if (perm)
                {
                    return(true);
                }
            }

            return(false);
        }