Skip to content

Instantly share code, notes, and snippets.

@mikebrind
Created October 2, 2018 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikebrind/a323d4e34a23357e96da2a9c15ba7c56 to your computer and use it in GitHub Desktop.
Save mikebrind/a323d4e34a23357e96da2a9c15ba7c56 to your computer and use it in GitHub Desktop.
public class PaginationModel : PageModel
{
private readonly IPersonService _personService;
public PaginationModel(IPersonService personService)
{
_personService = personService;
}
[BindProperty(SupportsGet = true)]
public int CurrentPage { get; set; } = 1;
public int Count { get; set; }
public int PageSize { get; set; } = 10;
public int TotalPages => (int)Math.Ceiling(decimal.Divide(Count, PageSize));
public List<Models.Person> Data { get; set; }
public bool ShowPrevious => CurrentPage > 1;
public bool ShowNext => CurrentPage < TotalPages;
public bool ShowFirst => CurrentPage != 1;
public bool ShowLast => CurrentPage != TotalPages;
public async Task OnGetAsync()
{
Data = await _personService.GetPaginatedResult(CurrentPage, PageSize);
Count = await _personService.GetCount();
}
}
@RajputVikashRana
Copy link

Hi, I am not find css. Paging is implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment