public async Task <IEnumerable <LicenceDTO> > SearchAsync(SearchLicence searchParams) { var liste = await _repo.SearchAsync(searchParams); var rtn = MapLicenceDTO.MapDataToDTO(liste); return(rtn); }
public async Task <List <Licence> > SearchAsync(SearchLicence searchParams, CancellationToken ct = default) { List <Licence> retour = await _context.Licence //.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 <LicencesModel> > Search([FromQuery] SearchLicence searchParams) { LicencesModel retour = new LicencesModel(); IEnumerable <LicenceDTO> 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); }