Example #1
0
        public IActionResult Index(int page = 1, int id = 0)
        {
            int            pageSize = 8;
            List <NewsDTO> news;

            if (id == 0)
            {
                news = newsManager.GetAll().Reverse().ToList();
            }
            else
            {
                news = newsManager.Get().Where(e => e.CourseId == id).Reverse().ToList();
            }
            var count = news.Count();
            var items = news.Skip((page - 1) * pageSize).Take(pageSize).ToList();

            PageViewModel  NewsPageViewModel = new PageViewModel(count, page, pageSize);
            IndexViewModel viewModel         = new IndexViewModel
            {
                NewsPageViewModel = NewsPageViewModel,
                News = items
            };

            return(View(viewModel));
        }
Example #2
0
        public IActionResult ShowNews(int id)
        {
            var article = newsManager.Get().Where(e => e.Id == id).FirstOrDefault();
            var image   = imageManager.Get().Where(e => e.Id == article.Image_Id).FirstOrDefault();

            return(View(new ShowNewsViewModel()
            {
                Article = article,
                Image = image
            }));
        }
Example #3
0
        public ActionResult Detail(int id)
        {
            NewsViewModel model = new NewsViewModel();

            model.News       = _newsMgr.GetNews();
            model.Newsdetail = _newsMgr.Get(id);
            return(View(model));
        }