示例#1
0
        private PageSection BuildSection(IPublishedContent websiteNode, string nodeAlias)
        {
            var node    = _nodeHelper.GetContent(websiteNode.GetPropertyValue <int>(nodeAlias));
            var builder = _buildersFactory.GetFirstBuilderThatApply(node.DocumentTypeAlias);

            return(builder != null ? new PageSection
            {
                PartialPath = builder.ViewName,
                ViewModel = builder.CreateViewModel(node)
            }
            : null);
        }
示例#2
0
        public BaseViewModel CreateViewModel(IPublishedContent content)
        {
            var articlesIdInString = content.GetPropertyValue <string>("articlesPicker");
            var articlesIds        = articlesIdInString.Split(new [] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
            var viewModel          = new ArticleListViewModel
            {
                Articles = new List <ArticleCardViewModel>(),
                Title    = content.GetPropertyValue <string>("header")
            };

            articlesIds.ForEach(articleId =>
            {
                var articleModel = _nodeHelper.GetContent(articleId);
                viewModel.Articles.Add(new ArticleCardViewModel
                {
                    Title            = articleModel.GetPropertyValue <string>("title"),
                    ShortDescription = articleModel.GetPropertyValue <string>("shortDescription"),
                    Tags             = articleModel.GetPropertyValue <string>("tags").Split(','),
                    CardImage        = articleModel.GetImage("cardImage", _nodeHelper).WithQuality(70).WithHeight(160).WithWidth(330).WithCrop(),
                    Url = articleModel.Url
                });
            });
            return(viewModel);
        }