public async Task <IEnumerable <IllustrationDTO> > SearchAsync(SearchIllustration searchParams) { var liste = await _repo.SearchAsync(searchParams); var rtn = MapIllustrationDTO.MapDataToDTO(liste); return(rtn); }
public async Task <List <Illustration> > SearchAsync(SearchIllustration searchParams, CancellationToken ct = default) { List <Illustration> retour = await _context.Illustration //.Include(v => v.Vehicule) //.Include(c => c.Conducteur) //.Include(s => s.StatutAmende) //.Include(t => t.TypeAmende) //.Where(x => (searchParams.VehiculeId == null ? 1 == 1 : x.VehiculeId == searchParams.VehiculeId)) //.Where(x => (searchParams.ConducteurId == null ? 1 == 1 : x.ConducteurId == searchParams.ConducteurId)) //.Where(x => (searchParams.TypeAmendeId == null ? 1 == 1 : x.TypeAmendeId == searchParams.TypeAmendeId)) //.Where(x => (searchParams.StatutAmendeId == null ? 1 == 1 : x.StatutAmendeId == searchParams.StatutAmendeId)) //.Where(x => (string.IsNullOrEmpty(searchParams.NumeroAmende) ? 1 == 1 : x.NumeroAmende.Contains(searchParams.NumeroAmende))) .Where(x => !x.IsDeleted) .OrderByDescending(on => on.DateCreation) .ToListAsync(); return(retour); }
public async Task <ActionResult <IllustrationsModel> > Search([FromQuery] SearchIllustration searchParams) { IllustrationsModel retour = new IllustrationsModel(); IEnumerable <IllustrationDTO> resultat = await _logic.SearchAsync(searchParams); retour.TotalCount = resultat.ToList().Count; resultat = resultat .Skip(searchParams.PageIndex * searchParams.PageSize) .Take(searchParams.PageSize) .ToList(); retour.Items = resultat; if (resultat == null) { logItem.Message += "Search Pas trouvé " + searchParams.ToString(); loggingService.WriteError(logItem); return(StatusCode(StatusCodes.Status404NotFound)); } return(retour); }