Exemplo n.º 1
0
        public bool InRoles(string roles)
        {
            if (string.IsNullOrWhiteSpace(roles))
            {
                return(false);
            }

            var rolesArray = roles.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var role in rolesArray)
            {
                var hasRole = UserRole.Any(p => string.Compare(p.Role.Code, role, true) == 0);
                if (hasRole)
                {
                    return(true);
                }
            }
            return(false);
        }