var express = require('express')
const router = express.Router();
const db = require("../../utils/database");
const dbFuntion = require("../../utils/dbfunction")
const { response } = require('express');


router.post("/deleteCIL",(req,res)=>{
    const id = req.body.id
    db.getConnection((err, connection) => {
        if (err) {
          console.log("database not connected error: >>>", err);
          res.send(500).status({
            msg: "Error from database",
            err: err,
          });
        }
        let dQuer=`delete from finehhdi_CIL.SetCIL where id=${id}`
        connection.query(dQuer,(err,data)=>{
            connection.release();
            if(err)
            {
                console.log(err)
                res.status(401).json({
                    message:"error! CIL cant be deleted for somereason",
                    results:"Failed"
                })
            }
            else{
                res.status(200).json({
                    message:"CIL Deleted Successfully",
                    results:"Success"
                })
    
            }
        })
      })
})

router.post("/deleteSetCIL",(req,res)=>{
    const id = req.body.id
    db.getConnection((err, connection) => {
        if (err) {
          console.log("database not connected error: >>>", err);
          res.send(500).status({
            msg: "Error from database",
            err: err,
          });
        }
        let dQuer=`delete from finehhdi_CIL.SETCIL1 where id=${id}`
        connection.query(dQuer,(err,data)=>{
            connection.release();
            if(err)

            {
                console.log(err)
                res.status(401).json({
                    message:"error! CIL cant be deleted for somereason",
                    results:"Failed"
                })
            }
            else{
                res.status(200).json({
                    message:"CIL Deleted Successfully",
                    results:"Success"
                })
    
            }
        })
      })
})


module.exports = router;