Exemple #1
0
        public override bool IsUserInRole(string username, string roleName)
        {
            using (SchemaDBContext context = new SchemaDBContext())
            {
                User user = context.Users.FirstOrDefault(u => u.Username.Equals(username, StringComparison.CurrentCultureIgnoreCase));

                string role = user.UserRole.Role;

                var roles = new string[] { role };

                if (user != null)
                {
                    return(roles.Any(r => r.Equals(roleName, StringComparison.CurrentCultureIgnoreCase)));
                }
                else
                {
                    return(false);
                }
            }
        }
Exemple #2
0
        public override string[] GetRolesForUser(string username)
        {
            using (SchemaDBContext context = new SchemaDBContext())
            {
                User user = context.Users.FirstOrDefault(u => u.Username.Equals(username, StringComparison.CurrentCultureIgnoreCase));

                System.Diagnostics.Debug.WriteLine(username);
                string role = user.UserRole.Role;

                var roles = new string[] { role };
                if (role != null)
                {
                    return(roles);
                }
                else
                {
                    return new string[] { }
                };;
            }
        }