public async Task <IActionResult> Index()
        {
            var model = new PartialsDemoIndexVm();

            model.NewsArticles = await _newsArticleService.GetNewsArticles();


            return(View(model));
        }
Beispiel #2
0
        public async Task <IViewComponentResult> InvokeAsync(bool sortDescending, int?maxItems)
        {
            var articles = await _newsArticleService.GetNewsArticles();

            //order in requested direction
            if (sortDescending)
            {
                articles = articles.OrderByDescending(e => e.CreationDate);
            }
            else
            {
                articles = articles.OrderBy(e => e.CreationDate);
            }

            //limit # items if needed
            if (maxItems.HasValue)
            {
                articles = articles.Take(maxItems.Value);
            }

            return(View(articles));
        }