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.Form, tableInfo); if (pagedRecords.Records.IsNullOrEmpty() && tableInfo.Page > 1) { return RedirectToAction( "Index", PrepareRouteValues( entityName, "1", pagedRecords.Filters, tableInfo)); } var url = Url.Action( "Index", PrepareRouteValues( entityName, "-page-", pagedRecords.Filters, tableInfo)) .Replace("-page-", "{0}"); var model = new EntitiesIndexModel(entity, pagedRecords, tableInfo, url) { Configuration = _configuration, ChangeEnabled = _admin.ChangeEntity != null }; return View(model); }
public virtual ActionResult Index(string entityName, TableInfo tableInfo) { var entity = AdminInitialise.EntitiesTypes .FirstOrDefault(x => x.Name == entityName); if (entity == null) { throw new NoNullAllowedException("entity is null"); } var filters = PrepareFilters(entity); var pagedRecords = _entitiesSource.GetRecords( entity, tableInfo.Page, tableInfo.PerPage, filters, tableInfo.SearchQuery, tableInfo.Order, tableInfo.OrderDirection); 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, TableInfo = tableInfo, Configuration = _configuration }; return View(model); }