public ActionResult Index(int page = 1) { ArticleModelFactory articleModelFactory = new ArticleModelFactory(); ArticleIndexModel model = articleModelFactory.LoadIndex(page); return(CheckViewModel(model)); }
public ActionResult Index(ArticleIndexModel model, int?page, bool isEn = false) { int defautPagesize = 10; int total = 0; int currentPageIndex = page.HasValue ? page.Value - 1 : 0; IArticlesService artSrv = IoC.Resolve <IArticlesService>(); ICategoryService categorySrv = IoC.Resolve <ICategoryService>(); string kw = String.IsNullOrWhiteSpace(model.Keyword) ? null : model.Keyword.Trim(); if (string.IsNullOrEmpty(model.CatID)) { model.CatID = "0"; } int cID = int.Parse(model.CatID); var list = artSrv.GetBySearch(HttpContext.User.Identity.Name, kw, cID, currentPageIndex, defautPagesize, out total); model.Categories = categorySrv.Query.Where(p => p.Active).OrderBy(p => p.NameVNI).ToList(); model.Articles = new PagedList <Articles>(list, currentPageIndex, defautPagesize, total); if (isEn) { return(View("Indexen", model)); } return(View(model)); }
public ActionResult Index(int id = 1) { ArticleIndexModel model = new ArticleIndexModel { Items = new List <ArticleItemModel>() }; model = articleService.GetArticles(2, id); model.SumOfArticle = articleService.GetCount(); return(View(model)); }
public ArticleIndexModel GetArticles(int pageSize, int pageIndex) { IList <Article> tempArticle = new List <Article>(); tempArticle = articleRepository.GetArticles(pageSize, pageIndex); ArticleIndexModel ArticleIndexModel = new ArticleIndexModel { Items = mapper.Map <List <ArticleItemModel> >(tempArticle) }; return(ArticleIndexModel); }
// GET: Admin/Article public ActionResult Index(ArticleIndexModel model, int?page) { var artSrv = IoC.Resolve <IArticleService>(); var artCatSrv = IoC.Resolve <IArticleCategoryService>(); var currentPage = page.HasValue ? page.Value - 1 : 0; var pageSize = 10; int total = 0; var lst = artSrv.GetByFilter(model.KeyWord, model.ParentCatId, model.CatId, currentPage, pageSize, out total); model.ArtCats = artCatSrv.GetParents(); model.Cats = artCatSrv.GetChilds(model.ParentCatId); model.Articles = new PagedList <Arcticle>(lst, currentPage, pageSize, total); return(View(model)); }
public ArticleIndexModel LoadIndex(int page) { ArticleIndexModel articleIndexModel = new ArticleIndexModel(); ArticleBusiness articleBusiness = new ArticleBusiness(); List <Article> articleList = articleBusiness.ArticleList(page); articleIndexModel.ArticleList = (from z in articleList select new ArticleItemModel { ID = z.ID, Name = z.ArticleTranslation.FirstOrDefault().Name }).ToList(); return(articleIndexModel); }
public async Task <IActionResult> Index(Guid topic, FilterType filter = FilterType.New, int page = 1) { if (page < 1) { return(NotFound()); } PagingResult <PostView> postViews = await postService.GetPagingResultAsync(topic, PostResultType.Article, page, filter); if (postViews.PageCount > 1 && page > postViews.PageCount) { return(NotFound()); } ArticleIndexModel model = new ArticleIndexModel { PostViews = postViews }; return(this.View(model)); }
public ActionResult ApproveIndex(ArticleIndexModel model, int?page, bool approved = false) { int defautPagesize = 10; int total = 0; int currentPageIndex = page.HasValue ? page.Value - 1 : 0; IArticlesService artSrv = IoC.Resolve <IArticlesService>(); ICategoryService categorySrv = IoC.Resolve <ICategoryService>(); model.Categories = categorySrv.Query.Where(p => p.Active).OrderBy(p => p.NameVNI).ToList(); string kw = String.IsNullOrWhiteSpace(model.Keyword) ? null : model.Keyword.Trim(); if (string.IsNullOrEmpty(model.CatID)) { model.CatID = model.Categories != null?model.Categories.FirstOrDefault().Id.ToString() : "0"; } int cID = int.Parse(model.CatID); var list = artSrv.ListForApprove(approved, kw, cID, currentPageIndex, defautPagesize, out total); model.Articles = new PagedList <Articles>(list, currentPageIndex, defautPagesize, total); ViewData["approved"] = approved; return(View(model)); }