当前位置: 首页>>代码示例>>C#>>正文


C# Pagination.Each方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:hakeemsm,项目名称:TheDessertHouse,代码行数:29,代码来源:ForumController.cs


注:本文中的System.Pagination.Each方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。