package com.progetto.VEBS.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.progetto.VEBS.model.dto.AreaVerdeDTO;
import com.progetto.VEBS.model.dto.IngressoAreaBluDTO;
import com.progetto.VEBS.model.entity.AreaVerde;
import com.progetto.VEBS.model.entity.IngressoAreaBlu;
import com.progetto.VEBS.service.IngressoAreaBluService;

@RestController
@RequestMapping("/ingressoblu")
public class IngressoAreaBluController {

	  @Autowired
	  private final IngressoService ingressoService;

	  public IngressoAreaBluController(IngressoAreaBluService ingressoAreaBluService) {
	    this.ingressoService = ingressoService;
	  }

	  @GetMapping()
	  List<IngressoAreaBluDTO> getAll() {
	        return ingressoAreaBluService.getAllIngressiAreeBlu();
	  }

	  @GetMapping("/{id_area_blu}")
	  IngressoAreaBluDTO getById(@PathVariable Integer id_ingresso) {
	    return ingressoAreaBluService.getIngressoAreaBluById(id_ingresso);
	  }
	  
	  @PostMapping("/save")
	  HttpStatus saveRecord(@RequestBody IngressoAreaBluDTO ingresso_area_blu) { 
		  ingressoAreaBluService.saveIngresso(ingresso_area_blu);
		  return HttpStatus.CREATED;
	  }
	  
	  @DeleteMapping("/delete/{id_ingresso}")
	  HttpStatus deleteRecord(@PathVariable Integer id_ingresso) {
		  ingressoAreaBluService.deleteIngressoAreaBluById(id_ingresso);
		  return HttpStatus.OK;
	  }
	  
	  @PatchMapping("/update")
	  HttpStatus updateRecord(@RequestBody IngressoAreaBluDTO ingresso) {
		  ingressoAreaBluService.updateIngressoAreaBlu(ingresso);
		  return HttpStatus.OK;
	  }
}
