// GET: Article public ActionResult Index(string page, string category, string searchWord) { int castPage = 1; if (!int.TryParse(page, out castPage)) { castPage = 1; } var articles = articleService.Get(searchWord, category, (castPage - 1), 6).To <ArticleViewModel>().ToList(); var total = (articleService.All().Count() / 6) + 1; var index = new ArticleIndexViewModel(); index.Arctiles = articles; index.ActivePage = castPage; index.TotalPage = total; index.Category = category; index.SearchWord = searchWord; var categories = this.articleCategoryService.All().Select(x => new SelectListItem() { Text = x.Name, Value = x.Name }).ToList(); categories.Add(new SelectListItem() { Text = "", Selected = true }); index.Categories = categories; return(View(index)); }
public ActionResult Index() { var model = new ArticleIndexViewModel(); model.Articles = _articleRepository.GetAll(); return(View(model)); }
// GET: ArticleModel public ActionResult Index() { ArticleIndexViewModel viewModel = new ArticleIndexViewModel(); var articles = db.Articles.Include(a => a.DictionaryType); viewModel.List = articles; return(View(viewModel)); }
public ActionResult ShowPopularity(string Account) { ArticleIndexViewModel Data = new ArticleIndexViewModel(); //取得頁面所需的人氣資料陣列 Data.DataList = articleService.GetPopularList(Account); return(View(Data)); }
// GET: Article public ActionResult Index() { var viewModel = new ArticleIndexViewModel { Articles = _articleRepository.GetAll().ToList(), ArticlePhotos = _articlePhotoRepository.GetAll().ToList(), ArticleComments = _articleCommentRepository.GetAll().ToList(), ArticleCategories = _articleCategoryRepository.GetAll().ToList() }; return(View(viewModel)); }
public IActionResult Index(int articleId) { ArticleIndexViewModel articleViewModel = new ArticleIndexViewModel { articleContent = articleContext.getArticleById(articleId), }; return(View(articleViewModel)); }
public async Task <IActionResult> Index() { var vm = new ArticleIndexViewModel { Articles = await articleRepository.GetAll(20) }; return(View(vm)); }
// GET: Admin/Articles public ActionResult Index(bool viewHtml = false) { var vm = new ArticleIndexViewModel() { Articles = _uow.Articles.AllWithTranslations(), ViewHtml = viewHtml }; return(View(vm)); }
// GET: Articles public async Task <IActionResult> Index(int id) { if (id == null) { return(NotFound()); } ArticleIndexViewModel articleIndex = new ArticleIndexViewModel(_context, id, (await GetCurrentUserAsync()).Id); return(View(articleIndex)); }
public async Task <ViewResult> IndexEdit() { var response = await this.articleService.GetEditArticlesAsync(new GetArticlesRequest { //LanguageId = base.LanguageId }); var model = new ArticleIndexViewModel { Articles = response.Articles }; return(View("index-edit", model)); }
public async Task<ViewResult> IndexEdit() { var response = await this.articleService.GetEditArticlesAsync(new GetArticlesRequest { //LanguageId = base.LanguageId }); var model = new ArticleIndexViewModel { Articles = response.Articles }; return View("index-edit", model); }
//文章列表,將頁數預設為1 public ActionResult List(string Search, string Account, int Page = 1) { //宣告一個新頁面模型 ArticleIndexViewModel Data = new ArticleIndexViewModel(); //將傳入值Search(搜尋)放入頁面模型中 Data.Search = Search; //新增頁面模型中的分頁 Data.Paging = new ForPaging(Page); //將此文章的擁有者的Account放入頁面模型中 Data.Account = Account; //從Service中取得頁面所需陣列資料 Data.DataList = articleService.GetDataList(Data.Paging, Data.Search, Data.Account); return(PartialView(Data)); }
// GET: Article public ActionResult Index(int?page) { var listAllArticle = GetListArticle(); var topFiveLatest = (from a in listAllArticle orderby a.CreatedAt descending select a).Take(5).ToList(); var listCategory = GetCategory(); var trendingArticle = (from a in listAllArticle orderby a.CreatedAt descending select a).Take(5).ToList(); //setting for paged list // 1. Tham số int? dùng để thể hiện null và kiểu int // page có thể có giá trị là null và kiểu int. // 2. Nếu page = null thì đặt lại là 1. if (page == null) { page = 1; } // 4. Tạo kích thước trang (pageSize) hay là số Link hiển thị trên 1 trang int pageSize = 6; // 4.1 Toán tử ?? trong C# mô tả nếu page khác null thì lấy giá trị page, còn // nếu page = null thì lấy giá trị 1 cho biến pageNumber. int pageNumber = (page ?? 1); var pagedList = listAllArticle.ToPagedList <Article>(pageNumber, pageSize); ArticleIndexViewModel model = new ArticleIndexViewModel() { AllArticles = listAllArticle, ListCategories = listCategory, TopFivesLatest = topFiveLatest, TrendingAricles = trendingArticle, PagedListArticle = pagedList }; return(View(model)); }
// GET: Article public ActionResult Index(string sortOrder = "Date", int page = 1, string parameters = "") { using (ISession session = NHibernateHelper.OpenSession()) { ParseParams(parameters, out string searchString, out string filterString); var articles = session.Query <Article>().Where(a => a.PubDate <= DateTime.Now && a.Visibility == true); DateFilter filter = new DateFilter(filterString); articles = filter.FilterByDate(articles); if (searchString != "") { articles = articles.Where(a => a.Title.Contains(searchString) || a.Description.Contains(searchString)); } articles = Sort(articles, sortOrder); var articlesList = articles.ToList(); int pageSize = 10; IEnumerable <Article> articlesPerPages = articlesList.Skip((page - 1) * pageSize).Take(pageSize); PageInfo pageInfo = new PageInfo { PageNumber = page, PageSize = pageSize, TotalItems = articlesList.Count }; ArticleIndexViewModel articlesViewModel = new ArticleIndexViewModel { Articles = articlesPerPages, PageInfo = pageInfo }; return(View(articlesViewModel)); } }