You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1002 B

8 months ago
const { pool } = require('../database')
/**
* function to get all Systeme note
* @returns promise
*/
async function getSysteme() {
8 months ago
const sql = 'SELECT * FROM notesystems'
try {
8 months ago
let [rows] = await pool.query(sql)
8 months ago
return rows[0]
} catch (error) {
return error
}
}
/**
* function to update systeme note
* @param {*} id
* @param {*} admis
* @param {*} redouble
* @param {*} renvoyer
* @returns promise
*/
async function updateSysteme(id, admis, redouble, renvoyer) {
8 months ago
const sql = 'UPDATE notesystems SET admis = ?, redouble = ?, renvoyer = ? WHERE id = ?'
try {
8 months ago
let [result] = await pool.query(sql, [admis, redouble, renvoyer, id])
8 months ago
if (result.affectedRows === 0) {
return {
success: false,
7 months ago
message: 'Année Scolaire non trouvé.'
8 months ago
}
}
return {
success: true,
7 months ago
message: 'Année Scolaire supprimé avec succès.'
8 months ago
}
} catch (error) {
return error
}
}
module.exports = {
getSysteme,
updateSysteme
}