package pl.dmcs.mati.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pl.dmcs.mati.domain.AppCar;
import pl.dmcs.mati.repository.AppCarRepository;

import java.util.List;
@Service
public class AppCarServiceImpl implements AppCarService{

    private AppCarRepository appCarRepository;

    @Autowired
    public AppCarServiceImpl(AppCarRepository appCarRepository) {

        this.appCarRepository = appCarRepository;

    }

    @Transactional
    public void addAppCar(AppCar appCar) {
        appCarRepository.save(appCar);
    }

    @Transactional
    public void editAppCar(AppCar appCar) {
        appCarRepository.save(appCar);
    }

    @Transactional
    public List<AppCar> listAppCar() {
        return appCarRepository.findAll();
    }

    @Transactional
    public void removeAppCar(long id) {
        appCarRepository.deleteById(id);
    }

    @Transactional
    public AppCar getAppCar(long id) {
        return appCarRepository.findById(id);
    }


}


