Ejemplo n.º 1
0
        public ContentResult Posts(JqInViewModel jqParams)
        {
            var posts      = _blogRepository.Posts(jqParams.page - 1, jqParams.rows, jqParams.sidx, jqParams.sord == "asc");
            var totalPosts = _blogRepository.TotalPosts(false);
            var post       = (from i in posts
                              select new
            {
                id = i.id.ToString(),
                Urlslug = i.UrlSlug,
                Title = i.Title,
                CategoryId = i.Category.id,
                Body = i.Body,
                UrlSlug = i.UrlSlug,

                CreatedOn = i.CreatedOn,
                Published = i.Published,
                Header = i.Header
            }
                              ).ToList();
            var result = Content(JsonConvert.SerializeObject(new
            {
                page    = jqParams.page,
                records = totalPosts,
                rows    = post,
                total   = Math.Ceiling(Convert.ToDouble(totalPosts) / jqParams.rows)
            }), "application/json");

            return(result);
        }