package fr.eni.enchere.bll;

import fr.eni.enchere.bo.Enchere;
import fr.eni.enchere.dal.EnchereRepository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EnchereServiceImpl implements EnchereService{

    private EnchereRepository enchereRepository;

    public EnchereServiceImpl(EnchereRepository enchereRepository) {
        this.enchereRepository = enchereRepository;
    }

    @Override
    public List<Enchere> enchereByUser(int idUser) {
        return enchereRepository.findByIdUser(idUser);
    }

    @Override
    public List<Enchere> enchereByArticle(int idArticle) {
        return enchereRepository.findByIdArticle(idArticle);
    }

    @Override
    public void setEnchere(Enchere enchere) {
        enchereRepository.save(enchere);
    }

    @Override
    public void deleteEnchere(int id) {
        this.enchereRepository.delete(id);
    }
}
