package fr.eni.enchere.bll;

import fr.eni.enchere.bo.Article;
import fr.eni.enchere.bo.SearchArticleCritere;
import fr.eni.enchere.dal.ArticleRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService{

    private ArticleRepository articleRepository;

    public ArticleServiceImpl(ArticleRepository articleRepository) {
        this.articleRepository = articleRepository;
    }
    @Override
    public List<Article> findAllArticle() {
        return articleRepository.findAllArticle();
    }

    @Override
    public List<Article> findByUser(int id) {
        return articleRepository.findByUser(id);
    }

    @Override
    public Article findArticleById(int id) {
        return articleRepository.findArticleById(id);
    }

    @Override
    public int saveArticle(Article article) {
        return articleRepository.saveArticle(article);
    }

    @Override
    public void deleteArticle(int id) {
        articleRepository.deleteArticle(id);
    }

    @Override
    public int updateArticle(Article article) {
        return articleRepository.updateArticle(article);
    }

    @Override
    public void setSellPrice(int id, float sellPrice) {
        this.articleRepository.setSellPrice(id, sellPrice);
    }

    @Override
    public List<Article> findArticleByTitle(String title) {
        return articleRepository.findArticleByTitle(title);
    }


    @Override
    public Page<Article> searchArticlePageable(SearchArticleCritere critere, Pageable pageable) {
        return articleRepository.searchArticlePageable(critere, pageable);
    }
}
