public async Task <IActionResult> GetCarsAsync(GetCars query) { var lang = LangCode; var result = await _carService.GetCarsAsync(query, lang); return(Ok(new { pageResult = result.Item1, pageCount = result.Item2 })); }
public async Task <(IEnumerable <CarOutputDto>, int)> GetCarsAsync(GetCars query, string lang) { var page = query.Page ?? 1 - 1; var pageSize = query.PageSize ?? 10; var cars = await _carRepository.Queryable() .Include(x => x.Color) .Include(x => x.Fuel) .Include(x => x.Owners) .Skip(page * pageSize) .Take(pageSize) .AsNoTracking() .ToListAsync(); int carsCount = await _carRepository.CountAsync(); List <CarOutputDto> carInputDtos = new List <CarOutputDto>(); foreach (var car in cars) { carInputDtos.Add(MapperCarToCarOutputDto(car, lang)); } (IEnumerable <CarOutputDto>, int)result = (carInputDtos, carsCount); return(result); }