public virtual ActionResult Index(string entityName, TableInfo tableInfo) { var entity = Admin.EntitiesTypes .FirstOrDefault(x => x.Name == entityName); if (entity == null) { throw new NoNullAllowedException("entity is null"); } entity.Fill(Request); var filters = _filterFactory.BuildFilters(entity).ToList(); var pagedRecords = _entitiesSource.GetRecords( entity, filters, tableInfo.SearchQuery, tableInfo.Order, tableInfo.OrderDirection, false, tableInfo.Page, tableInfo.PerPage); if (pagedRecords.Records.IsNullOrEmpty() && tableInfo.Page > 1) { return(RedirectToAction( "Index", PrepareRouteValues( entityName, "1", filters, tableInfo))); } var url = Url.Action( "Index", PrepareRouteValues( entityName, "-page-", filters, tableInfo)) .Replace("-page-", "{0}"); var model = new EntitiesIndexModel { Data = pagedRecords.Records, Columns = entity.DisplayProperties .Select(x => new Column(x, tableInfo.Order, tableInfo.OrderDirection)).ToList(), Entity = entity, Pager = new PagerInfo(url, tableInfo.PerPage, tableInfo.Page, pagedRecords.TotalItems), Filters = filters.Where(x => x.DisplayInUI).ToList(), TableInfo = tableInfo, Configuration = _configuration }; return(View(model)); }
private IEnumerable <BaseFilter> BuildFilters( Entity entity, NameValueCollection request, Action <IList <BaseFilter> > filtersMutator) { var filterRecord = create_filter_record(entity, request); var filters = _filterFactory.BuildFilters(filterRecord).ToList(); filtersMutator?.Invoke(filters); return(filters); }