コード例 #1
0
        public override string[] GetUsersInRole(string roleName)
        {
            int id = int.Parse(roleName);
            var dbcxt = new GazSimpleUsersDbContext();
            var urrepo = new UserRolesRepository(dbcxt);
            var role = urrepo.GetByID(id, r => r.Users);

            return role.Users.Select(s => s.Username).ToArray();
        }
コード例 #2
0
 public override bool ValidateUser(string login, string password)
 {
     var dbcxt = new GazSimpleUsersDbContext();
     var urepo = new UserRepository(dbcxt);
     currUser = urepo.LoginUser(login, password);
     if (currUser != null)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
コード例 #3
0
        public override string[] GetRolesForUser(string username)
        {
            int roleId = 0;

            using (var dbcxt = new GazSimpleUsersDbContext())
            {
                var urepo = new UserRepository(dbcxt);
                roleId = urepo.GetUserRoleByUsername(username);
            }

            if (roleId == 0 || !rolemap.ContainsKey(roleId)) return new string[] { };

            return new string[] { rolemap[roleId] };
        }
コード例 #4
0
        public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            if(currUser == null){
                var dbcxt = new GazSimpleUsersDbContext();
                var urepo = new UserRepository(dbcxt);
                currUser = urepo.GetAll().FirstOrDefault(u => u.Username == username);

                if(currUser != null) return null;

                MembershipUser user = new MembershipUser(currUser.FirstName, currUser.FirstName, null, currUser.Email, string.Empty,
                    string.Empty, true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now);

                return user;
            }

            return null;
        }