YourITGroup / MemberListView

Back-Office Member Management for Umbraco 7 & 8
27 stars 18 forks source link

Paging uses wrong pageindex #50

Open niekvanderreest opened 7 months ago

niekvanderreest commented 7 months ago

Hi,

The MemberExtendedService has a bug in the PerformExamineSearch function, this causes the first page to load when you click "next" or "2" in the pager, and makes the last page inaccessible.

The problem is following code, it already has a pageindex and substracts 1 from is, causing index:0 to be -1 and index 1 to be 0, and so on. I made my own implementation of the servcie and registered it, to confirm that removing the "-1" fixes this problem

if (pageSize > 0)
{
    int skipCount = (pageIndex > 0 && pageSize > 0) ? Convert.ToInt32((pageIndex -1) * pageSize) : 0;
    if (totalRecords < skipCount)
    {
        skipCount = (int)totalRecords / pageSize;
    }

    return results.Skip(skipCount).Take(pageSize);
}