Ejemplo n.º 1
0
        public ViewResult Index()
        {
            ViewBag.HideTitle = true;
            IList <Article> latestArticles             = repoArticle.Articles(take: 11);
            IList <Article> articlesByCategorySection1 = repoCategory.Categories(page: 1, take: 1).FirstOrDefault() != null?repoArticle.Articles(categoryID : repoCategory.Categories(page : 1, take : 1).FirstOrDefault().CategoryID, take : 4) : null;

            IList <Article> articlesByCategorySection2 = repoCategory.Categories(page: 2, take: 1).FirstOrDefault() != null?repoArticle.Articles(categoryID : repoCategory.Categories(page : 2, take : 1).FirstOrDefault().CategoryID, take : 4) : null;

            IList <Article> articlesByCategorySection3 = repoCategory.Categories(page: 3, take: 1).FirstOrDefault() != null?repoArticle.Articles(categoryID : repoCategory.Categories(page : 3, take : 1).FirstOrDefault().CategoryID, take : 4) : null;

            IList <Article> articlesByCategorySection4 = repoCategory.Categories(page: 4, take: 1).FirstOrDefault() != null?repoArticle.Articles(categoryID : repoCategory.Categories(page : 4, take : 1).FirstOrDefault().CategoryID, take : 4) : null;

            ArticleListPageViewModel articleListViewModel = new ArticleListPageViewModel
            {
                LatestArticles             = latestArticles,
                ArticlesByCategorySection1 = articlesByCategorySection1,
                ArticlesByCategorySection2 = articlesByCategorySection2,
                ArticlesByCategorySection3 = articlesByCategorySection3,
                ArticlesByCategorySection4 = articlesByCategorySection4,
                ContentExternalUrl         = repoConfig.Get(ConfigurationKeyStatic.CONTENT_EXTERNAL_URL)
            };

            ViewBag.Title       = repoConfig.Get(ConfigurationKeyStatic.MAIN_TITLE);
            ViewBag.Description = repoConfig.Get(ConfigurationKeyStatic.MAIN_DESCRIPTION);
            return(View(articleListViewModel));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> Index()
        {
            var user        = User;
            var ArticleList = await _articleClient.GetArticlePageByCategory("", 1);

            var pageTotalCount = ArticleList.TotalCount % 10 == 0 ? ArticleList.TotalCount / 10 : ArticleList.TotalCount / 10 + 1;
            ArticleListPageViewModel viewModel = new ArticleListPageViewModel
            {
                PageIndex      = 1,
                PageTotalCount = pageTotalCount,
                CategoryId     = "",
                ResultPage     = ArticleList
            };

            return(View(viewModel));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public async Task <IActionResult> ArticleList(string categoryId, int pageIndex = 1)
        {
            var ArticleList = await _articleClient.GetArticlePageByCategory(categoryId, pageIndex);

            var pageTotalCount = ArticleList.TotalCount % 10 == 0 ? ArticleList.TotalCount / 10 : ArticleList.TotalCount / 10 + 1;

            ArticleListPageViewModel viewModel = new ArticleListPageViewModel
            {
                PageIndex      = pageIndex,
                PageTotalCount = pageTotalCount,
                CategoryId     = categoryId,
                ResultPage     = ArticleList
            };

            return(View(viewModel));
        }
        public override ActionResult Index(ArticleListPage currentPage)
        {
            _model = PageViewModelBuilder.Create(currentPage);

            // create our view model and parser
            var viewModel = new ArticleListPageViewModel();

            viewModel.Heading = _model.CurrentPage.Heading.ToString();
            viewModel.Ingress = _model.CurrentPage.Ingress.ToString();

            /*var parser = new VueParser();*/ // in the real app you would use DI

            // in a real app, this would be placed somewhere in the base controller
            //viewModel.VueData = parser.ParseData(viewModel);

            _model.CurrentPage.ArticleListPageViewModel = viewModel;

            return(View(_model));
        }