import { json } from "express";
import ParkingSlot from "../models/ParkingSlotModels.js";

export const parkingSlotCreate = async (req,res) => {
   try{

    const parkingSlot = await ParkingSlot.create(req.body);
    res.status(201).json(parkingSlot);
   }catch (error){
    res.status(500).json({message:error.message});
   }
};
//read

export const getParkingSlot = async (req,res) => {
   try{
      const parkingSlot = await ParkingSlot.find();
      res.status(200).json(parkingSlot);
   }catch(error){
res.status(500).json({message:error.message});
   }
};

//update
export const updatepakingSlot = async (req,res) =>{
   try{
      const parkingSlot = await ParkingSlot.findByIdAndUpdate(req.params.id, req.body, {new:true});
   res.status(200).json(pakingSlot);
   }catch(error){
res.status(500).json({message:error.message});
   }
};

//delete
export const deleteParkingSlot = async (req,res) => {
   try{
      const parkingSlot = await ParkingSlot.findByIdAndDelete(req.params.id);
      res.status(200).json({message:"parking slot deleted"});
   }catch(error){
      res.status(500).json({message:error.message});
   }
};
