public async Task <Tuple <int, List <FaqGroupDTO> > > LoadAsyncCount( int skip = -1, int take = -1, FaqGroupSearchViewModel model = null) { var query = Entities.ProjectTo <FaqGroupDTO>(); if (!string.IsNullOrEmpty(model.Title)) { query = query.Where(x => x.Title.Contains(model.Title)); } int Count = query.Count(); query = query.OrderByDescending(x => x.Id); if (skip != -1) { query = query.Skip((skip - 1) * take); } if (take != -1) { query = query.Take(take); } return(new Tuple <int, List <FaqGroupDTO> >(Count, await query.ToListAsync())); }
public async Task <IActionResult> Index(FaqGroupSearchViewModel searchModel) { var model = await _faqGroupRepository.LoadAsyncCount( this.CurrentPage, this.PageSize, searchModel); this.TotalNumber = model.Item1; ViewBag.SearchModel = searchModel; return(View(model.Item2)); }