package bg.car_wash.areas.car.serviceImpl;

import bg.car_wash.areas.car.entity.Car;
import bg.car_wash.areas.car.exception.CarDBEmptyException;
import bg.car_wash.areas.car.repository.CarRepository;
import bg.car_wash.areas.car.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarServiceImpl implements CarService {

	@Autowired
	private CarRepository carRepository;

	@Override
	public void createCar(Car car){
		this.carRepository.save(car);
	}

	@Override
	public List<Car> findAllCars() {
		List<Car> cars = this.carRepository.findAll();
		if (cars.isEmpty()) {
			throw new CarDBEmptyException("Not found cars in DB", 404);
		}

		return cars;
	}
}

@@ -138,16 +138,77 @@
 eption;%0A
+import bg.car_wash.areas.car.exception.CarNotFoundException;%0A
 import b
@@ -834,11 +834,202 @@
 cars;%0A%09%7D
+%0A%0A%09@Override%0A%09public void deleteCarById(Long id) throws CarNotFoundException %7B%0A%09%09//TODO throw new CarNotFoundExcception after not success delete car%0A%09%09this.carRepository.deleteCarById(id);%0A%09%7D
 %0A%7D%0A

add delete car by id