public override ActionResult Index(RenderModel model) { var allSections = model.Content.Children.ToList(); var listOfSectionsToRender = _sectionsProvider.GetListOfSectionsToRender(allSections); var pageViewModel = new PageViewModel { Sections = listOfSectionsToRender }; return(View("Page", _pageModelExtender.ApplyLayoutToModel(pageViewModel, model.Content))); }
public override ActionResult Index(RenderModel model) { var rootNodes = _nodeHelper.Umbraco.TypedContentAtRoot(); var articlesRootNode = rootNodes.First(x => x.DocumentTypeAlias == "articlesRoot"); var allArticles = articlesRootNode.Children.SelectMany(x => x.Children).ToList(); var parsedArticles = allArticles.Select(x => new MetadataForAllList { Title = x.Name, Url = x.Url, Date = x.CreateDate }).ToList(); var grupedArticlesList = new List <GrupedArticles>(); var index = 0; parsedArticles.ForEach(article => { var parsedDate = article.Date.ToString("Y", CultureInfo.GetCultureInfoByIetfLanguageTag("pl")).ToFirstUpper(); if (grupedArticlesList.Any(x => x.NodeName == parsedDate)) { var monthList = grupedArticlesList.First(x => x.NodeName == parsedDate); monthList.Articles.Add(article); } else { grupedArticlesList.Add(new GrupedArticles { Order = index, NodeName = parsedDate, Articles = new List <MetadataForAllList> { article } }); index++; } }); var pageViewModel = _pageModelExtender.ApplyLayoutToModel(new PageViewModel(), model.Content); grupedArticlesList.ForEach(x => { x.Articles = x.Articles.OrderByDescending(y => y.Date).ToList(); }); var allArticlesViweModel = new AllArticlesViewModel { Header = pageViewModel.Header, Description = "Wszystkie posty pogrupowane po miesiącu publikacji", Title = "Wszystkie posty", Footer = pageViewModel.Footer, IsArticle = false, Id = pageViewModel.Id, GrupedArticles = grupedArticlesList.OrderByDescending(x => x.Order).ToList() }; return(View("AllArticles", allArticlesViweModel)); }
public override ActionResult Index(RenderModel model) { var allSections = model.Content.Children.ToList(); var listOfSectionsToRender = _sectionsProvider.GetListOfSectionsToRender(allSections); var pageViewModel = new PageViewModel { Sections = listOfSectionsToRender }; pageViewModel = _pageModelExtender.ApplyLayoutToModel(pageViewModel, model.Content); var rootNodes = _nodeHelper.Umbraco.TypedContentAtRoot(); var websiteNode = rootNodes.First(x => x.DocumentTypeAlias == "master"); var articleViewModel = pageViewModel.ExtendToArticleViewModel(model.Content, websiteNode); var image = model.Content.GetImage("cardImage", _nodeHelper).WithQuality(75).WithHeight(160).WithWidth(330).WithCrop(); var request = HttpContext.Request; var domainurl = string.Format("{0}://{1}", request.Url.Scheme, request.Url.Authority); articleViewModel.ArticleImgUrl = domainurl + image.Url; articleViewModel.Image = model.Content.GetImage("cardImage", _nodeHelper).WithQuality(75).WithHeight(400).WithWidth(1170).WithCrop(); articleViewModel.PublishedOn = model.Content.CreateDate; return(View("Article", articleViewModel)); }
public override ActionResult Index(RenderModel model) { var pageViewModel = new PageViewModel(); var extendedModel = _pageModelExtender.ApplyLayoutToModel(pageViewModel, model.Content); var tagName = Request.QueryString["tag"]; var articles = new List <ArticleCardViewModel>(); var articlesWithTag = _nodeHelper.Umbraco.TagQuery.GetContentByTag(tagName).ToList(); var header = $"Posty otagowane {tagName}"; articlesWithTag.ForEach(article => { articles.Add(new ArticleCardViewModel { Title = article.GetPropertyValue <string>("title"), ShortDescription = article.GetPropertyValue <string>("shortDescription"), Tags = article.GetPropertyValue <string>("tags").Split(','), CardImage = article.GetImage("cardImage", _nodeHelper).WithQuality(75).WithHeight(160).WithWidth(330).WithCrop(), Url = article.Url }); }); var modelForArticles = new ArticleListViewModel { Title = header, Articles = articles }; var viewModel = new ArticleByTagViewModel { Id = extendedModel.Id, Title = header, Footer = extendedModel.Footer, Header = extendedModel.Header, Description = "Lista wszystkich postów które zosta³y otagowane " + tagName, ArticlesListModel = modelForArticles }; return(View("Tag", viewModel)); }