private async Task <OutletListVM> GetElementsAsync(int?page, string keyword) { var vm = new OutletListVM() { Keyword = keyword, PageIndex = page ?? 1, PageSize = SettingsManager.Outlet.PageSize }; var query = _db.Outlets.AsQueryable(); if (!string.IsNullOrEmpty(keyword)) { query = query.Where(d => d.Name.Contains(keyword) || d.Address.Contains(keyword)); } var list = await query.AsNoTracking().OrderByDescending(d => d.Importance) .Skip((vm.PageIndex - 1) * vm.PageSize).Take(vm.PageSize).ProjectTo <OutletVM>().ToListAsync(); //_teamServices.GetOutletdElements(pageListVM.PageIndex - 1, pageListVM.PageSize, pageListVM.Keyword, out totalCount); vm.TotalCount = await query.CountAsync(); vm.Outlets = new StaticPagedList <OutletVM>(list, vm.PageIndex, vm.PageSize, vm.TotalCount);; return(vm); }
//private readonly IOutletServices _teamServices; //private readonly IPageMetaServices _pageMetaServices; //private IMapper _mapper; //public OutletController(IOutletServices teamServices, IPageMetaServices pageMetaServices, IMapper mapper) //{ // _teamServices = teamServices; // _pageMetaServices = pageMetaServices; // _mapper = mapper; //} // GET: Admin/Outlets public async Task <ActionResult> Index(int?page, string keyword) { OutletListVM pageListVM = await GetElementsAsync(page, keyword); ViewBag.PageSizes = new SelectList(Site.PageSizes()); return(View(pageListVM)); }