public JsonResult Factures([FromBody] Pagination pagination) { if (pagination != null) { var results = _formationService.GetFactures(); if (!String.IsNullOrEmpty(pagination.Search)) { results = _formationService.GetFactures().Where(i => i.BonCommande.Contains(pagination.Search) || i.Entreprise.Nom.Contains(pagination.Search)); } int totalRows = results.Count(); Util.Paginate <Facture>(pagination, ref results); var rows = results.ToList(); var filteredTotalRows = rows.Count(); return(Json(new { Rows = rows, FilteredTotalRows = filteredTotalRows, TotalRows = totalRows })); } else { return(Json(new { Rows = new List <Facture>(), FilteredTotalRows = 0, TotalRows = 0 })); } }