Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Paul Aikman 43 posts 97 karma points
    Jun 17, 2015 @ 14:57
    Paul Aikman
    0

    MemberResource.getPagedResults Filter Options?

    I'm trying to use the angular MemberResource in the back office to return a list of filtered members (specifically, those with umbracoMemberApproved as true/false). If I put any filter in, it just returns 0 results. Leaving the filter blank works.

    Unfortunately I'm not having much luck figuring out how the filters work - does anyone know what the correct syntax is?

    Here's what I have so far (reverse engineered from the source):

    var defaults = {
        pageSize: 25,
        pageNumber: 1,
        filter: 'umbracoMemberApproved=1', // what goes here??
        orderDirection: "Ascending",
        orderBy: "LoginName"
    };
    
    memberResource.getPagedResults('all-members', defaults).then(function (data) {
        $scope.memberData = data;
    });
    

    Cheers,

    Paul

  • Carl Jackson 139 posts 478 karma points
    Jun 17, 2015 @ 16:36
    Carl Jackson
    0

    try the MemberRepoitory

    from line 645.

    Not had chance to look but ulitmately that is wher your string ends up!

    Thanks

    Carl

  • Paul Aikman 43 posts 97 karma points
    Jun 18, 2015 @ 08:43
    Paul Aikman
    1

    Yeah I saw this bit:

    args.Add("%" + filter + "%");
    

    But didn't know if that was only actually for the members table and not the properties etc (members table only has like 2 fields - name and email or similar).

    I ended up just creating a new API controller so I could use the "proper" MembershipService, which took around 5 minutes...

    public class MyMembershipServiceController : UmbracoAuthorizedJsonController
    {
        [HttpGet]
        public PagedList<IMember> GetApprovedMembers()
        {
            var memberService = UmbracoContext.Application.Services.MemberService;
    
            var approvedMembers = memberService.GetMembersByPropertyValue("umbracoMemberApproved",
            false);
    
            return new PagedList<IMember>(approvedMembers);
        }
    }
    

    Ta,

    P

Please Sign in or register to post replies

Write your reply to:

Draft