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)); }
public virtual ActionResult Index(string entityName, TableInfo tableInfo) { var entity = _admin.GetEntity(entityName); if (entity == null) { throw new NoNullAllowedException("entity is null"); } var pagedRecords = _recordsService.GetRecords(entity, Request.QueryString, tableInfo); if (pagedRecords.Records.IsNullOrEmpty() && tableInfo.Page > 1) { return(Redirect(Url.PageUrl(1))); } var model = new EntitiesIndexModel(entity, pagedRecords, tableInfo) { Configuration = _configuration, ChangeEnabled = _admin.ChangeEntity != null }; return(View(model)); }