public virtual void PopulateModel(L model) { BaseRepo <T> repo = SetRepo(); TryUpdateModel(model); Expression <Func <T, bool> > filter = model.Filter.GenerateFilter(); model.Items = repo.GetAll(filter, model.Pager.CurrentPage, model.Pager.PageSize).ToList(); int resultCount = repo.Count(filter); model.Pager.PagesCount = (int)Math.Ceiling(resultCount / (double)model.Pager.PageSize); }
public virtual ActionResult Index() { AllVM model = CreateBaseAllVM(); model.Pager = new Pager(); model.Filter = new FilterVM(); TryUpdateModel(model); model.Filter.Prefix = "Filter."; int resultCount = repo.Count(model.Filter.BuildFilter()); string prefix = "Pager."; string action = this.ControllerContext.RouteData.Values["action"].ToString(); string controller = this.ControllerContext.RouteData.Values["controller"].ToString(); model.Pager = new Pager(resultCount, model.Pager.CurrentPage, model.Pager.PageSize, prefix, action, controller); model.Filter.ParentPager = model.Pager; model.Items = repo.GetAll(model.Filter.BuildFilter(), model.Pager.CurrentPage, model.Pager.PageSize.Value).ToList(); return(View(model)); }
public int Count(Expression <Func <T, bool> > filter) { return(repo.Count(filter)); }
protected virtual int Count() { return(repo.Count()); }