public ActionResult DataSource(string postId, int pageIndex)
        {
            var list          = _commentService.GetListByPost(postId);
            var pageParameter = new PageParameter(pageIndex, 10);

            list = pageParameter.Paged(list);
            var model = list.ToArray().Select(i => (CommentListViewModel)i).ToArray();

            return(Json(new { pageParameter.PageCount, list = model }));
        }
        public ActionResult DataSource(int pageIndex, int pageSize, string titleKeywords)
        {
            var table = _categoryService.GetList(titleKeywords);

            var pageParameter = new PageParameter(pageIndex, pageSize);
            table = pageParameter.Paged(table);
            var model = table.Select(i => new CategoryListViewModel
            {
                Id = i.Id,
                PostCount = i.Posts.Count(),
                Title = i.Title,
                Visible = i.Visible,
                Seo = i.Seo,
                RoutePath = i.Route.Path
            }).ToArray();

            return Json(new { pageParameter.PageCount, list = model });
        }
        public ActionResult DataSource(int pageIndex, int pageSize, string titleKeywords, string category)
        {
            var table = _postService.GetList(titleKeywords, category);

            var pageParameter = new PageParameter(pageIndex, pageSize);
            table = pageParameter.Paged(table);
            var model = table.Select(i => new PostListViewModel
            {
                Id = i.Id,
                CommentCount = i.Comments.Count(),
                CreateTime = i.CreateTime,
                ReadingCount = i.ReadingCount,
                Status = i.Status,
                Title = i.Title
            }).ToArray();

            return Json(new { pageParameter.PageCount, list = model });
        }
        public ActionResult DataSource(int pageIndex, int pageSize, string titleKeywords, string category)
        {
            var table = _postService.GetList(titleKeywords, category);

            var pageParameter = new PageParameter(pageIndex, pageSize);

            table = pageParameter.Paged(table);
            var model = table.Select(i => new PostListViewModel
            {
                Id           = i.Id,
                CommentCount = i.Comments.Count(),
                CreateTime   = i.CreateTime,
                ReadingCount = i.ReadingCount,
                Status       = i.Status,
                Title        = i.Title
            }).ToArray();

            return(Json(new { pageParameter.PageCount, list = model }));
        }
Beispiel #5
0
        public ActionResult DataSource(int pageIndex, int pageSize, string titleKeywords)
        {
            var table = _categoryService.GetList(titleKeywords);

            var pageParameter = new PageParameter(pageIndex, pageSize);

            table = pageParameter.Paged(table);
            var model = table.Select(i => new CategoryListViewModel
            {
                Id        = i.Id,
                PostCount = i.Posts.Count(),
                Title     = i.Title,
                Visible   = i.Visible,
                Seo       = i.Seo,
                RoutePath = i.Route.Path
            }).ToArray();

            return(Json(new { pageParameter.PageCount, list = model }));
        }
        public async Task<HttpResponseMessage> Get(string postId, int pageIndex, int pageSize)
        {
            if (!await _postService.Exist(postId))
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, "文章不存在!");

            var comments = _commentService.GetListByPost(postId);

            var pageParameter = new PageParameter(pageIndex - 1, pageSize);
            comments = pageParameter.Paged(comments);

            return Request.CreateResponse(HttpStatusCode.OK,
                new
                {
                    pageParameter.PageCount,
                    PageIndex = pageIndex,
                    pageParameter.PageSize,
                    Data = comments.ToArray().Select(i => new { i.Id, i.Content, i.NickName, i.CreateTime })
                });
        }
Beispiel #7
0
        private ActionResult List(int pageIndex, IQueryable <PostRecord> queryable, SeoModelFull seo, bool allowNotData = false)
        {
            if (pageIndex <= 0)
            {
                return(HttpNotFound());
            }

            var posts = queryable;

            if (posts == null)
            {
                return(HttpNotFound());
            }

            dynamic model = new ExpandoObject();

            model.Seo      = seo;
            model.PostPage = null;

            if (!posts.Any() && allowNotData)
            {
                return(View("List", model));
            }

            var pageParameter = new PageParameter(pageIndex - 1, 10);

            posts = pageParameter.Paged(posts);

            model.PostPage           = new ExpandoObject();
            model.PostPage.PageCount = pageParameter.PageCount;
            model.PostPage.PageIndex = pageParameter.PageIndex;
            model.PostPage.PageSize  = pageParameter.PageSize;
            model.PostPage.Posts     = posts;

            if (pageIndex > pageParameter.PageCount || !posts.Any())
            {
                return(HttpNotFound());
            }

            return(View("List", model));
        }
        public async Task <HttpResponseMessage> Get(string postId, int pageIndex, int pageSize)
        {
            if (!await _postService.Exist(postId))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "文章不存在!"));
            }

            var comments = _commentService.GetListByPost(postId);

            var pageParameter = new PageParameter(pageIndex - 1, pageSize);

            comments = pageParameter.Paged(comments);

            return(Request.CreateResponse(HttpStatusCode.OK,
                                          new
            {
                pageParameter.PageCount,
                PageIndex = pageIndex,
                pageParameter.PageSize,
                Data = comments.ToArray().Select(i => new { i.Id, i.Content, i.NickName, i.CreateTime })
            }));
        }
Beispiel #9
0
        private ActionResult List(int pageIndex, IQueryable<PostRecord> queryable, SeoModelFull seo, bool allowNotData = false)
        {
            if (pageIndex <= 0)
                return HttpNotFound();

            var posts = queryable;
            if (posts == null)
                return HttpNotFound();

            dynamic model = new ExpandoObject();
            model.Seo = seo;
            model.PostPage = null;

            if (!posts.Any() && allowNotData)
                return View("List", model);

            var pageParameter = new PageParameter(pageIndex - 1, 10);
            posts = pageParameter.Paged(posts);

            model.PostPage = new ExpandoObject();
            model.PostPage.PageCount = pageParameter.PageCount;
            model.PostPage.PageIndex = pageParameter.PageIndex;
            model.PostPage.PageSize = pageParameter.PageSize;
            model.PostPage.Posts = posts;

            if (pageIndex > pageParameter.PageCount || !posts.Any())
                return HttpNotFound();

            return View("List", model);
        }