Last active
August 29, 2015 14:09
-
-
Save nul800sebastiaan/9189c212e4237882d520 to your computer and use it in GitHub Desktop.
PopulatePaging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void PopulatePaging(Stream stream) | |
{ | |
const int pageSize = 5; | |
var skipItems = (pageSize * stream.Page) - pageSize; | |
var posts = stream.Content.Children.ToList(); | |
stream.TotalPages = Convert.ToInt32(Math.Ceiling((double)posts.Count() / pageSize)); | |
stream.PreviousPage = stream.Page - 1; | |
stream.NextPage = stream.Page + 1; | |
stream.IsFirstPage = stream.Page <= 1; | |
stream.IsLastPage = stream.Page >= stream.TotalPages; | |
stream.StatusUpdates = posts.OrderByDescending(x => x.CreateDate).Skip(skipItems).Take(pageSize); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment