public IActionResult Index(Models.BlogListPage currentPage)
        {
            var model = new BlogListPageViewModel(currentPage)
            {
                SubNavigation = GetSubNavigation(currentPage)
            };

            var pageId     = currentPage.ContentLink.ID;
            var pagingInfo = new PagingInfo
            {
                PageId = pageId
            };

            if (currentPage.Template == TemplateSelections.Card || currentPage.Template == TemplateSelections.Insight)
            {
                pagingInfo.PageSize = 6;
            }

            var viewModel = GetViewModel(currentPage, pagingInfo);

            model.Blogs      = viewModel.Blogs;
            model.PagingInfo = pagingInfo;

            return(View(model));
        }
        public BlogListPageViewModel GetViewModel(Models.BlogListPage currentPage, PagingInfo pagingInfo)
        {
            var      categoryQuery = Request.Query["category"].ToString() ?? string.Empty;
            IContent category      = null;

            if (categoryQuery != string.Empty)
            {
                if (int.TryParse(categoryQuery, out var categoryContentId))
                {
                    // Geta Categories
                    //var content = _contentLoader.Get<StandardCategory>(new ContentReference(categoryContentId));

                    var fakeContent = _contentLoader.Get <IContent>(new ContentReference(categoryContentId));
                    if (fakeContent != null)
                    {
                        category = fakeContent;
                    }
                }
            }
            var pageSize = pagingInfo.PageSize;

            // TODO: Need a better solution to get data by page
            var blogs = FindPages(currentPage, category).ToList();

            blogs = Sort(blogs, currentPage.SortOrder).ToList();
            pagingInfo.TotalRecord = blogs.Count;

            if (pageSize > 0)
            {
                if (pagingInfo.PageCount < pagingInfo.PageNumber)
                {
                    pagingInfo.PageNumber = pagingInfo.PageCount;
                }
                var skip = (pagingInfo.PageNumber - 1) * pageSize;
                blogs = blogs.Skip(skip).Take(pageSize).ToList();
            }

            var model = new BlogListPageViewModel(currentPage)
            {
                Heading    = category != null ? "Blog tags for post: " + category.Name : string.Empty,
                PagingInfo = pagingInfo
            };

            model.Blogs = blogs.Select(x => GetBlogItemPageViewModel(x, model));
            return(model);
        }
        private BlogItemPageViewModel GetBlogItemPageViewModel(PageData currentPage, BlogListPageViewModel blogModel)
        {
            var pd = (BlogItemPage.Models.BlogItemPage)currentPage;

            PreviewTextLength = 200;

            var model = new BlogItemPageViewModel(pd)
            {
                Tags             = /*GetTags(pd)*/ new List <TagItem>(),
                PreviewText      = GetPreviewText(pd),
                ShowIntroduction = blogModel.ShowIntroduction,
                ShowPublishDate  = blogModel.ShowPublishDate,
                Template         = blogModel.CurrentContent.Template,
                PreviewOption    = blogModel.CurrentContent.PreviewOption,
                StartPublish     = currentPage.StartPublish ?? DateTime.UtcNow
            };

            return(model);
        }