public virtual JsonResult GetTableData(DataRequest dataRequest) { var filterResult = _entityController.GetEntities(dataRequest); var totalCountBeforeSkipAndTake = filterResult.Count(); filterResult = filterResult.Skip((dataRequest.Page - 1) * dataRequest.PageSize); filterResult = filterResult.Take(dataRequest.PageSize); var result = new EntitiesResult <TEntity> { Entities = _entityController.ToViewModels(filterResult.ToList()), TotalCount = totalCountBeforeSkipAndTake }; return(Json(result)); }
internal new EntitiesResult <TEntity> GetEntities(DataRequest dataRequest) { var entities = base.GetEntities(dataRequest).ToList(); var filteredEntities = new List <TEntity>(); if (dataRequest.Taxonomies != null) { foreach (var entity in entities) { foreach (var kv in dataRequest.Taxonomies) { var taxonomies = TaxonomyHelper.GetTaxonomiesForEntity <TEntityTaxonomy>(entity.Id, kv.Key).Select(o => o.TaxonomyId); if (taxonomies.Contains(kv.Value)) { filteredEntities.Add(entity); break; } } } } else { filteredEntities = entities; } var entityResult = new EntitiesResult <TEntity> { TotalCount = filteredEntities.Count }; if (dataRequest.Page != 0) { filteredEntities = filteredEntities.Skip((dataRequest.Page - 1) * dataRequest.PageSize).ToList(); } if (dataRequest.PageSize != 0) { filteredEntities = filteredEntities.Take(dataRequest.PageSize).ToList(); } entityResult.Entities = ToViewModels(filteredEntities, dataRequest.AdditionalFields); return(entityResult); }