示例#1
0
        // GET: /<controller>/
        public Task <IActionResult> IndexAsync([FromQuery] ArticlesListFilter filter, CancellationToken ct)
        {
            var parameters = filter ?? new ArticlesListFilter();
            var articlesVm = new ArticlesIndexViewModel();

            var articles = ctx.Articles.ToList();

            foreach (var article in articles)
            {
                articlesVm.Articles.Add(new ArticleViewModel
                {
                    PublicationDate = article.PublicationDate,
                    Name            = article.Name
                });
            }

            return(Task.FromResult <IActionResult>(View("Index", articlesVm)));
        }
示例#2
0
        // GET: Admin/Articles
        public ActionResult Index(int page = 1)
        {
            ArticlesIndexViewModel model = new ArticlesIndexViewModel
            {
                Articles = articleRepository.Articles
                           .OrderBy(article => article.Id)
                           .Skip((page - 1) * pageSize)
                           .Take(pageSize),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = pageSize,
                    TotalItems   = articleRepository.Articles.Count()
                },
                CurrentCategory = null
            };

            return(View(model));
        }
示例#3
0
        // GET: Articles
        public ActionResult Index(string category, int page = 1)
        {
            ArticlesIndexViewModel model = new ArticlesIndexViewModel
            {
                Articles = repository.Articles
                           .Where(article => category == null || article.Category.UrlName == category)
                           .OrderBy(article => article.Id)
                           .Skip((page - 1) * pageSize)
                           .Take(pageSize),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = pageSize,
                    TotalItems   = category == null?
                                   repository.Articles.Count() :
                                       repository.Articles.Where(article => article.Category.UrlName == category).Count()
                },
                CurrentCategory = category
            };

            return(View(model));
        }