public DatatableQueryResultViewModel GetAllQueryableAsDatatable(DatatableQueryInputViewModel datatableQuery) { string textToSearch = datatableQuery.TextToSearch; var predicate = new Func <Procedimento, bool>((p) => textToSearch.Contains(p.Id.ToString()) || textToSearch.Contains(p.BoletimUnificado) || textToSearch.Contains(p.BoletimOcorrencia) || textToSearch.Contains(p.NumeroProcessual) || textToSearch.Contains(p.TipoProcedimento.Sigla) || textToSearch.Contains(p.CriadoEm.ToString()) || textToSearch.Contains(p.BoletimOcorrencia) || textToSearch.Contains(p.Comarca.Nome) || textToSearch.Contains(p.BoletimOcorrencia)); var result = Enumerable.Empty <Procedimento>(); if (string.IsNullOrEmpty(textToSearch)) { result = Repository.GetPaged(DatatableColumns[datatableQuery.OrderColumn], datatableQuery.Start, datatableQuery.Length); } else { result = Repository.GetPaged(x => predicate(x), DatatableColumns[datatableQuery.OrderColumn], datatableQuery.Start, datatableQuery.Length); } return(new DatatableQueryResultViewModel { Draw = datatableQuery.Draw, RecordsFiltered = result.Count(), Data = result.Select(p => new List <object> { string.Empty, p.Id, p.BoletimUnificado, p.BoletimOcorrencia, p.NumeroProcessual, p.TipoProcedimento.Sigla, p.CriadoEm, p.Comarca.Nome, p.AndamentoProcessual }).ToList(), RecordsTotal = Repository.Count() }); }
public IActionResult GetAsDatatableQuery([FromQuery] int draw, [FromQuery(Name = "order[0][column]")] int orderColumn, [FromQuery(Name = "order[0][dir]")] string orderDir, [FromQuery] int start, [FromQuery] int length, [FromQuery(Name = "search[value]")] string searchText) { var input = new DatatableQueryInputViewModel { Draw = draw, OrderColumn = orderColumn == 0 ? 1 : orderColumn, OrderDir = orderDir, Start = start, Length = length, TextToSearch = searchText }; return(Response(_procedimentoAppService.GetAllQueryableAsDatatable(input))); }