79 lines
2.1 KiB
JavaScript
79 lines
2.1 KiB
JavaScript
//import functions from checklist solutions model
|
|
import {
|
|
insertChecklistSolutionTodo,
|
|
getChecklistSolutionTodosById,
|
|
getChecklistSolutionTodosByAsset,
|
|
updateChecklistSolutionTodoById,
|
|
deleteAllChecklistSolutionTodosSolutionID,
|
|
deleteChecklistSolutionTodo,
|
|
} from "../models/checklistSolutionsModel.js";
|
|
|
|
//create new checklist solution todo
|
|
export const createChecklistSolutionTodos = (req, res) => {
|
|
const data = req.body;
|
|
insertChecklistSolutionTodo(data, (err, results) => {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
res.json(results);
|
|
}
|
|
});
|
|
};
|
|
|
|
//get single checklist solution todos by id
|
|
export const showChecklistSolutionTodosById = (req, res) => {
|
|
getChecklistSolutionTodosById(req.params.id, (err, results) => {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
res.json(results);
|
|
}
|
|
});
|
|
};
|
|
|
|
//get single checklist solution todos by asset
|
|
export const showChecklistSolutionTodosByAsset = (req, res) => {
|
|
getChecklistSolutionTodosByAsset(req.params.id, (err, results) => {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
res.json(results);
|
|
}
|
|
});
|
|
};
|
|
|
|
// Update checklist solution todo
|
|
export const updateChecklistSolutionTodo = (req, res) => {
|
|
const data = req.body;
|
|
updateChecklistSolutionTodoById(data, (err, results) => {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
res.json(results);
|
|
}
|
|
});
|
|
};
|
|
|
|
// Delete checklist solution todos by solution ID
|
|
export const deleteChecklistSolutionTodosSolutionID = (req, res) => {
|
|
const id = req.params.id;
|
|
deleteAllChecklistSolutionTodosSolutionID(id, (err, results) => {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
res.json(results);
|
|
}
|
|
});
|
|
};
|
|
|
|
// Delete checklist solution todos by primaryID
|
|
export const deleteChecklistSolutionTodos = (req, res) => {
|
|
const id = req.params.id;
|
|
deleteChecklistSolutionTodo(id, (err, results) => {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
res.json(results);
|
|
}
|
|
});
|
|
}; |