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.AreaVerdeMapper;
import com.progetto.VEBS.model.dto.AreaVerdeDTO;
import com.progetto.VEBS.model.repository.AreaVerdeRepository;

@Service
public class AreaVerdeService {
	
	@Autowired
	private AreaVerdeMapper mapper;
	
	@Autowired
	private AreaVerdeRepository areaVerdeRepository;

	public List<AreaVerdeDTO> getAllAreeVerdi() {
	    return areaVerdeRepository.findAll().stream()
	        .map(mapper::toDTO)
	        .collect(Collectors.toList());
	}

	public AreaVerdeDTO getAreaVerdeById(Integer id) {
	    return areaVerdeRepository.findById(id).map(mapper::toDTO)
	            .orElse(null);
	}
	
}
