private IQueryable <TEntity> ProcessQuery(DataTableRequestDTO dataFilter, IQueryable <TEntity> data) { if (dataFilter.Filters != null && dataFilter.Filters.Any()) { data = ProcessQueryFilter(dataFilter.Filters, data); } if (dataFilter.Columns != null && dataFilter.Order != null && dataFilter.Columns.Any() && dataFilter.Order.Any() && dataFilter.Order.All(o => o != null && !string.IsNullOrEmpty(o.Dir) && o.Column >= 0)) { data = TableOrderBy(dataFilter, data); } if (dataFilter.Start >= 0 && dataFilter.Length > 0) { data = data .Skip(dataFilter.Start) .Take(dataFilter.Length); } return(data); }
private async Task <IEnumerable <IssueDTO> > GetQueryiedForCurrentUser( DataTableRequestDTO model, bool isCustomer) { return(isCustomer ? await _issueService.GetIssuesByCurrentUser() : await _filterServiceFactory.GetService <IssueDTO>().GetQueriedAsync(model)); }
public virtual async Task <IActionResult> Filter(DataTableRequestDTO model) { return(Json( ComposeDataTableResponseDto( await GetMappedEntitiesByModel(model), model, await _filterServiceFactory.GetService <TEntityDto>().TotalRecordsAmountAsync()))); }
private async Task <IQueryable <TEntity> > DetermineDataSource(DataTableRequestDTO dataFilter) => dataFilter.Search != null && !string.IsNullOrEmpty(dataFilter.Search.Value) ? await _queryRepository.SearchExpressionAsync( dataFilter.Search.Value .Split(new[] { ' ', ',', '.' }, StringSplitOptions.RemoveEmptyEntries) .Select(x => x.Trim().ToUpperInvariant()) ) : _queryRepository.GetQueryable();
public override async Task <IActionResult> Filter(DataTableRequestDTO model) { var isCustomer = User.FindFirst(RoleNames.Schema)?.Value == RoleNames.Register; return(Json( ComposeDataTableResponseDto( await GetQueryiedForCurrentUser(model, isCustomer), model, await GetTotalRecordsForCurrentUser(isCustomer)))); }
public virtual async Task <IActionResult> Filter( int issueId, DataTableRequestDTO model) { var dtResponse = ComposeDataTableResponseDto( await GetMappedEntitiesByIssueId(issueId), model, await _filterServiceFactory.GetService <IssueLogDTO>().TotalRecordsAmountAsync()); dtResponse.RecordsFiltered = (ulong)dtResponse.Data.LongLength; return(Json(dtResponse)); }
private IQueryable <TEntity> TableOrderBy(DataTableRequestDTO dataFilter, IQueryable <TEntity> data) { data = data.OrderBy( dataFilter.Columns[dataFilter.Order[0].Column].Data, dataFilter.Order[0].Dir == DataTableRequestDTO.DataTableDescending ); for (var i = 1; i < dataFilter.Order.Length; ++i) { data = data.ThenBy( dataFilter.Columns[dataFilter.Order[i].Column].Data, dataFilter.Order[i].Dir == DataTableRequestDTO.DataTableDescending ); } return(data); }
public virtual async Task <IList <TEntity> > GetQueriedAsync(DataTableRequestDTO dataFilter) { bool searchNotEmpty = dataFilter.Search != null && !string.IsNullOrEmpty(dataFilter.Search.Value); IQueryable <TEntity> entities; if (searchNotEmpty) { entities = await _queryRepository.SearchAsync(dataFilter.SearchEntries); } else { entities = _queryRepository.GetQueryable(); } var queryable = ProcessQuery(dataFilter, entities); return(await queryable.ToListAsync()); }
protected virtual DataTableResponseDTO ComposeDataTableResponseDto( IEnumerable <TEntityDto> res, DataTableRequestDTO model, ulong totalAmount, string errorMessage = "") { return(new DataTableResponseDTO { Draw = (ulong)model.Draw, Data = res.ToArray(), RecordsTotal = totalAmount, RecordsFiltered = (model.Filters != null && model.Filters.Any()) || (model.Search != null && !string.IsNullOrEmpty(model.Search.Value)) ? (ulong)res.Count() : totalAmount, Error = errorMessage, }); }
public async Task <IEnumerable <TDto> > GetQueriedAsync(DataTableRequestDTO dataFilter) { return(_mapper.Map <IEnumerable <TDto> >( await _filterService.GetQueriedAsync(dataFilter) )); }
protected async Task <IEnumerable <TEntityDto> > GetMappedEntitiesByModel(DataTableRequestDTO model) { return(await _filterServiceFactory.GetService <TEntityDto>().GetQueriedAsync(model)); }
protected virtual Task <IQueryable <TEntity> > GetQueriedAsync( DataTableRequestDTO dataFilter, IQueryable <TEntity> dataSource) => Task.FromResult(ProcessQuery(dataFilter, dataSource));
public virtual async Task <IEnumerable <TEntity> > GetQueriedAsync(DataTableRequestDTO dataFilter) => await GetQueriedAsync(dataFilter, await DetermineDataSource(dataFilter));