import Payment from "../models/PaymentModels.js";

export const paymentCreate = async (req,res) =>{
    try{
        const payment = await Payment.create (req.body);
        res.status(200).json(payment);
    }catch(error){
   res.status(500).json({message:error.message});
    }
};
//read

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

//update

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

//delete

export const deletePayment = async (req,res) => {
    try{
        const payment = await Payment.findByIdAndDelete(req.params.id);
        res.status(200).json({message:"parking slot deleted"});
    }catch(error){
        res.status(500).json({message:error.message});
    }
};