本文整理汇总了C#中System.Pagination.Each方法的典型用法代码示例。如果您正苦于以下问题:C# Pagination.Each方法的具体用法?C# Pagination.Each怎么用?C# Pagination.Each使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Pagination
的用法示例。
在下文中一共展示了Pagination.Each方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewPost
public ActionResult ViewPost(int postId, string path, int pageNum = 1)
{
using (var repository = _repositoryProvider.GetRepository())
{
var post = repository.Get<ForumPost>().Where(f => f.Id == postId).FirstOrDefault();
if (post == null)
return HttpNotFound("No post found with Id " + postId);
if (!string.Equals(path, post.Path, StringComparison.OrdinalIgnoreCase))
return RedirectToActionPermanent("ViewForum", new { postId, path = post.Path });
post.ViewCount++;
int pageSize = DessertHouseConfigurationSection.Current.Forums.PostReplyPageSize;
var forumPostView = Mapper.Map<ForumPost, ForumPostView>(post);
var replies = post.Replies.Where(r=>r.Approved).Skip((pageNum - 1) * pageSize).Take(pageSize);
forumPostView.Replies = Mapper.Map<IEnumerable<ForumPost>, IEnumerable<ForumPostReplyView>>(replies);
var postReplies = new Pagination<ForumPostReplyView>(forumPostView.Replies, pageNum, pageSize, post.Replies.Count);
postReplies.Each(p => p.Avatar = GetLastPostByAvatarUrl(p, 16));
forumPostView.PagedReplies = postReplies;
post.Replies.Each(p=>p.ViewCount++);
repository.Save(post);
forumPostView.Avatar = GetLastPostByAvatarUrl(forumPostView, 16);
var vote =
repository.Get<ForumPostVote>().Where(v => v.Post.Id == postId && v.AddedBy == User.Identity.Name).
SingleOrDefault();
forumPostView.UserVote = vote == null ? 0 : vote.Direction;
ViewBag.PageTitle = string.Format("{0} Forum", post.Title);
return View(forumPostView);
}
}