public async Task <Tuple <int, List <SuggestionsAndComplaintDTO> > > LoadAsyncCount( int skip = -1, int take = -1, SuggestionsAndComplaintSearchViewModel model = null) { var query = Entities.ProjectTo <SuggestionsAndComplaintDTO>(); if (!string.IsNullOrEmpty(model.Name)) { query = query.Where(x => x.Name.Contains(model.Name)); } if (!string.IsNullOrEmpty(model.Family)) { query = query.Where(x => x.Name.Contains(model.Family)); } 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 <SuggestionsAndComplaintDTO> >(Count, await query.ToListAsync())); }
public async Task <IActionResult> Index(SuggestionsAndComplaintSearchViewModel searchModel = null) { var model = await _suggestionsAndComplaintRepository.LoadAsyncCount( this.CurrentPage, this.PageSize, searchModel); this.TotalNumber = model.Item1; ViewBag.SearchModel = searchModel; return(View(model.Item2)); }