possible to use 'Member' as model for WebApi Controller?
I'd like to use a WebApi to look up members by role (got it working) and wondering if I can return the list of members directly rather than use a custom made model.
I don't know why it's not working, but you shouldn't use the Member object for this. It's not cached. You should return an IPublishedContent. More info: http://issues.umbraco.org/issue/U4-4379
Thanks Jeroen. I now receive an exception 'Unable to cast object of type 'Umbraco.Core.Models.Member' to type 'Umbraco.Core.Models.IPublishedContent'.'
Should I not use the memberserice.getmembersinrole method?
Could you let me know how to select the members by role as IPublishedContent?
I haven't used the member helpers a lot. In the link I provided above should be some examples. However it could be possible that the method your looking for doesn't exist yet. For 7.2.5 there is this feature: http://issues.umbraco.org/issue/U4-6368.
Thanks for sending this link - it appears there are plans to add more methods to the MembershipHelper.
If I use the MemberService.GetMembersInRole method and return a custom model rather than a Member object would I avoid the downside of the Member object not being cached?
I'm looking for the most efficient way to query members and return the selected data - just can't determine what that is.
The member service is used for editing data and not for fetching data. So it's always slower. You should always try to return the data as an IPublishedContent, but I'm not sure if those methods are available yet.
Yes, the speed is indeed the issue with our current implementation. It is slow, and it is the reason we are trying to utilize the WebApi and use AJAX to load sections of the member list based on the users geographic location.
I will try it with the MemberService and check the speed. If it is not a big improvement, I will make a new Document Type to store the needed Member information keep it synchronized with Member data with some kind of code.
possible to use 'Member' as model for WebApi Controller?
I'd like to use a WebApi to look up members by role (got it working) and wondering if I can return the list of members directly rather than use a custom made model.
Method in the controller:
public IEnumerable<Member> GetUsersInRole(string memberType)
{
return Services.MemberService.GetMembersInRole(memberType).Cast<Member>().ToArray();
}
However getting an exception message: No set method for property 'ContentTypeAlias' in type 'Umbraco.Core.Models.Member'.
If possible, I'd like to avoid creating a model just to map all of the member properties into a new object.
thanks for any advice which might help.
Steve
Hello,
I don't know why it's not working, but you shouldn't use the Member object for this. It's not cached. You should return an IPublishedContent. More info: http://issues.umbraco.org/issue/U4-4379
Jeroen
Thanks Jeroen. I now receive an exception 'Unable to cast object of type 'Umbraco.Core.Models.Member' to type 'Umbraco.Core.Models.IPublishedContent'.'
Should I not use the memberserice.getmembersinrole method?
Could you let me know how to select the members by role as IPublishedContent?
Steve
Hello,
I haven't used the member helpers a lot. In the link I provided above should be some examples. However it could be possible that the method your looking for doesn't exist yet. For 7.2.5 there is this feature: http://issues.umbraco.org/issue/U4-6368.
Jeroen
Hello Jeroen,
Thanks for sending this link - it appears there are plans to add more methods to the MembershipHelper.
If I use the MemberService.GetMembersInRole method and return a custom model rather than a Member object would I avoid the downside of the Member object not being cached?
I'm looking for the most efficient way to query members and return the selected data - just can't determine what that is.
thanks,
Steve
The member service is used for editing data and not for fetching data. So it's always slower. You should always try to return the data as an IPublishedContent, but I'm not sure if those methods are available yet.
Jeroen
Yes, the speed is indeed the issue with our current implementation. It is slow, and it is the reason we are trying to utilize the WebApi and use AJAX to load sections of the member list based on the users geographic location.
I will try it with the MemberService and check the speed. If it is not a big improvement, I will make a new Document Type to store the needed Member information keep it synchronized with Member data with some kind of code.
Thanks again for your help.
Steve
is working on a reply...