コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
 public int Count(Expression <Func <T, bool> > filter)
 {
     return(repo.Count(filter));
 }
コード例 #4
0
 protected virtual int Count()
 {
     return(repo.Count());
 }