import ParkingRecord from "../models/ParkingRecordModelss.js";

export const parkingRecordCreate = async (req,res) => {
    try{
        const parkingRecord = await ParkingRecord.create(req.body);
        res.status(201).json(parkingRecord);
    }catch(error){
   res.status(500).json({message:error.message});
    }
};
 
//read
export const getParkingRecord = async (req,res) => {
    try{
        const parkingRecord = await ParkingRecord.find();
        res.status(200).json(parkingRecord);
    }catch(error){
        res.status(500).json({message:error.message});
    }
};

//update

export const updateParkingRecord = async (req,res) => {
    try{
        const parkingRecord = await ParkingRecord.findByIdAndUpdate(req.params.id, req.body, {new:true});
        res.status(200).json(parkingRecord);
    }catch(error){
        res.status(500).json({message:error.message});
    }
};

//delete

export const deleteParkingRecord = async (req,res) => {
    try{
        const parkingRecord = await ParkingRecord.findByIdAndDelete(req.params.id);
        res.status(200).json({message:"car deleted successfully"});
    }catch(error){
        res.status(500).json({message:error.message});
    }
};