public async Task <IActionResult> Index(FeatureQuestionForPakageSearchViewModel searchModel) { var model = await _featureQuestionForPakageRepository.LoadAsyncCount( this.CurrentPage, this.PageSize, searchModel); this.TotalNumber = model.Item1; ViewBag.SearchModel = searchModel; ViewBag.Groups = await _productGroupRepository.GetParentsAsync(); ViewBag.Features = _featureRepository.GetAllMap <FeatureIdTitleDTO>(); return(View(model.Item2)); }
public async Task <Tuple <int, List <FeatureQuestionForPakageDTO> > > LoadAsyncCount( int skip = -1, int take = -1, FeatureQuestionForPakageSearchViewModel model = null) { var query = Entities.ProjectTo <FeatureQuestionForPakageDTO>(); if (!string.IsNullOrEmpty(model.QuestionTitle)) { query = query.Where(x => x.QuestionTitle.Contains(model.QuestionTitle)); } if (model.FeatureId != 0) { query = query.Where(x => x.FeatureId == model.FeatureId); } if (model.GroupId != 0) { query = query.Where(x => x.GroupId == model.GroupId); } 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 <FeatureQuestionForPakageDTO> >(Count, await query.ToListAsync())); }