示例#1
0
        public override bool IsUserInRole(string username, string roleName)
        {
            SeniorDBEntities db = new SeniorDBEntities();
            var user            = db.Users.Where(a => a.username.ToLower() == username.ToLower()).FirstOrDefault();

            if (user == null)
            {
                return(false);
            }
            return(user.Role.Name.ToLower() == roleName.ToLower());
        }
示例#2
0
        public override string[] GetRolesForUser(string username)
        {
            string[]         roles = { Constants.ROLES.GUEST };
            SeniorDBEntities db    = new SeniorDBEntities();
            var user = db.Users.Where(a => a.username.ToLower() == username.ToLower()).FirstOrDefault();

            if (user != null)
            {
                return new string[] { user.Role.Name }
            }
            ;

            return(roles);
        }