public override bool IsUserInRole(string username, string roleName)
 {
     var usersContext = new UsersContext();
     var user = usersContext.Users.SingleOrDefault(u => u.UserName == username);
     if (user == null)
         return false;
     return user.UserRoles != null && user.UserRoles.Select(
          u => u.Role).Any(r => r.RoleName == roleName);
 }
 public override string[] GetRolesForUser(string username)
 {
     var usersContext = new UsersContext();
     //var user = usersContext.Users.SingleOrDefault(u => u.UserName == username);
     var user = usersContext.GetUser(username);
     if (user == null)
         return new string[] { };
     return user.UserRoles == null
         ? new string[] { }
         : GetUserRoles(user.UserId).Select(u => u.Role).Select(u => u.RoleName).ToArray();
     //user.UserRoles.Select(u => u.Role).Select(u => u.RoleName).ToArray();
 }
 public override string[] GetAllRoles()
 {
     var usersContext = new UsersContext();
     return usersContext.Roles.Select(r => r.RoleName).ToArray();
 }