Example #1
0
        public Car GetById(int id)
        {
            var car = new CarRepository().GetById(id);

            if (car == null)
            {
                return(null);
            }

            var photosRepository = new PhotosRepository();
            var photos           = photosRepository.GetByCarId(car.Id);

            car.Photos = photos.Any() ? photos : null;

            return(car);
        }
Example #2
0
        public List <Car> GetCars(Filters filters)
        {
            var cars = new CarRepository().GetAll().ByFilters(filters);

            if (!cars.Any())
            {
                return(cars);
            }

            var photosRepository = new PhotosRepository();

            foreach (var car in cars)
            {
                var photos = photosRepository.GetByCarId(car.Id);
                car.Photos = photos.Any() ? photos : null;
            }

            return(cars);
        }