package web.ParkingSpotRelated;

import pojo.ParkingSpot;
import service.ParkingSpotService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet(urlPatterns = "/main/admin/Spots")
public class SpotStatusServlet extends HttpServlet {
    ParkingSpotService service = new ParkingSpotService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<ParkingSpot> parkingSpots = null;
        try {
            parkingSpots = service.getAllSpots();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        req.setAttribute("parkingSpots", parkingSpots);
        req.getRequestDispatcher("/main/admin/adminSpots.jsp").forward(req, resp);
    }
}


