In orchard 1.6 I want to get all the records in the Orchard_Users_UserPartRecord table
I can get a user by saying:
var user = _membershipService.GetUser(username);
or
IUser userInfo = _authenticationService.GetAuthenticatedUser();
is there not a query or service of some sort that allows me to getAllUsers?...im sure there is but I cant see it so iv tried to add my own...
In Orchard.Users module in the membershipService.cs iv added:
public IEnumerable<IUser> GetAllUsers()
{
return _orchardServices.ContentManager.Query<UserPart, UserPartRecord>().List();
}
tehn in the IUserService iv added:
IEnumerable<IUser> AllUsers();
and in the userService iv added:
public IEnumerable<IUser> AllUsers()
{
IEnumerable<IUser> users = _membershipService.//but it doesnt allow me to select GetAllUsers, but it does allow me to seleect
//getUser, iv used the same code only changed the query why isnt it showing?
if (users == null)
return null;
return users;
}
then where I needed to get all users I can say:
IEnumerable<IUser> allUsers = _userService.AllUsers();
I think there is a service that already does this I just dont see it. ANy ideas?
GetAllUsers()
is not available on_membershipService
, because_membershipService
is of the interface typeIMembershipService
, and not of theMembershipService
class, where you added theGetAllUsers()
method. To make this available, also add the method declaration forGetAllUsers()
to theIMembershipService
interface.As for whether a service already exists for doing this, it doesn't seem that way. You can see that Orchard itself uses the same technique as you described above to obtain a list of users, such as in the
AdminController
that comes with theOrchard.Users
module: