Example #1
0
        public ActionResult Index(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));
        }
Example #2
0
        private BlogItemPageViewModel GetBlogItemPageViewModel(PageData currentPage, BlogListPageViewModel blogModel)
        {
            var pd = (BlogItemPage.BlogItemPage)currentPage;

            PreviewTextLength = 200;

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

            return(model);
        }
Example #3
0
        public BlogListPageViewModel GetViewModel(BlogListPage currentPage, PagingInfo pagingInfo)
        {
            var      categoryQuery = Request.QueryString["category"] ?? string.Empty;
            IContent category      = null;

            if (categoryQuery != string.Empty)
            {
                if (int.TryParse(categoryQuery, out var categoryContentId))
                {
                    var content = _contentLoader.Get <StandardCategory>(new ContentReference(categoryContentId));
                    if (content != null)
                    {
                        category = content;
                    }
                }
            }
            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);
        }
        public ActionResult Index(Cms.Pages.BlogListPage currentPage)
        {
            var model = new BlogListPageViewModel(currentPage)
            {
                SubNavigation = GetSubNavigation(currentPage)
            };

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

            var viewModel = GetViewModel(currentPage, pagingInfo);

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

            return(View(model));
        }
        public ActionResult Preview(PageData currentPage, BlogListPageViewModel blogModel, bool?flip)
        {
            var pd = (BlogItemPage)currentPage;

            PreviewTextLength = 200;

            var model = new BlogItemPageModel(pd)
            {
                Tags             = GetTags(pd),
                PreviewText      = GetPreviewText(pd),
                ShowIntroduction = blogModel.ShowIntroduction,
                ShowPublishDate  = blogModel.ShowPublishDate,
                Template         = blogModel.CurrentContent.Template,
                PreviewOption    = blogModel.CurrentContent.PreviewOption,
                StartPublish     = currentPage.StartPublish ?? DateTime.UtcNow,
                Flip             = flip ?? false
            };

            return(PartialView("Preview", model));
        }
Example #6
0
        public async Task <ActionResult> Index(Cms.Pages.BlogListPage currentPage)
        {
            await _trackingService.PageViewed(HttpContext, currentPage);

            var model = new BlogListPageViewModel(currentPage);

            model.SubNavigation = GetSubNavigation(currentPage);

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

            var viewModel = GetViewModel(currentPage, pagingInfo);

            model.Blogs      = viewModel.Blogs;
            model.PagingInfo = pagingInfo;
            return(View(model));
        }