package com.progetto.VEBS.service;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.progetto.VEBS.mapper.AreaBluMapper;
import com.progetto.VEBS.model.dto.AreaBluDTO;
import com.progetto.VEBS.model.repository.AreaBluRepository;

@Service
public class AreaBluService {

	@Autowired
	private AreaBluMapper mapper;
	
	@Autowired
	private AreaBluRepository areaBluRepository;

	public List<AreaBluDTO> getAllAreeBlu() {
	    return areaBluRepository.findAll().stream()
	        .map(mapper::toDTO)
	        .collect(Collectors.toList());
	}

	public AreaBluDTO getAreaBluById(Integer id) {
	    return areaBluRepository.findById(id).map(mapper::toDTO)
	            .orElse(null);
	}
}
