private bool CanPerformActionOnGroup(AuthorizationContext context)
        {
            var action = context.Action.FirstOrDefault();

            if (context.Resource.Count() < 2)
            {
                return(false);                // We need the resource, which will be the group claim type, and a 2nd with the group id.
            }
            if (action == null)
            {
                throw new NotSupportedException("Cannot validate claim action check on null action for a department resource.");
            }

            return(context.Principal.HasClaim(
                       ResgridClaimTypes.CreateGroupClaimTypeString(int.Parse(context.Resource[1].Value)), action.Value));
        }
        private bool CanPerformActionOnDepartment(AuthorizationContext context)
        {
            var action = context.Action.FirstOrDefault();

            if (action == null)
            {
                throw new NotSupportedException("Cannot validate claim action check on null action for a department resource.");
            }

            var departments = context.Principal.Claims.Where(x => x.Type == ResgridClaimTypes.Memberships.Departments);

            if (departments.Count() == 1)
            {
                return(context.Principal.HasClaim(ResgridClaimTypes.CreateDepartmentClaimTypeString(int.Parse(departments.First().Value)), action.Value));
            }

            return(false);
        }