--- a/controllers/controllerV0.js
+++ b/controllers/controllerV0.js
@@ -77,7 +77,6 @@
sendResponse(200, {success:true},"Create Rules: "+response, res);
}
})
-
}else{
logger.error(handler);
res.end();
@@ -189,15 +188,29 @@
logger.info("Request type: ",req.method, "Request URL: ", req.originalUrl);
var handler = "backend.controllers.editRule";
logger.info("Starting: ",handler);
- database.updateRule(req.body, function(isOK, data){
- if(!isOK) {
- logger.info(handler,data);
- sendResponse(500, {success:false, data:rows},"Update Rule: "+data, res);
- }else {
- logger.info(handler,data);
- sendResponse(200, {success: true, data:data},"Update Rule: Success",res);
- }
- });
+ var response = [];
+ if(Object.keys(req.body).length != 0){
+ req.body.forEach(function(eachBody, index){
+ database.updateRule(eachBody, function(isOK, data){
+ if(!isOK) {
+ logger.info(handler,data);
+ response.push({description: eachBody.description, success: false})
+
+ }else {
+ logger.info(handler,data);
+ response.push({description: eachBody.description, success: true })
+ }
+ });
+ if(req.body.length-1 == index){
+ sendResponse(200, {success: true, response:response},"Update Rule: Success",res);
+ }
+ })
+
+ }else{
+ logger.error(handler);
+ res.end();
+ }
+
}
module.exports.getAllRule= function (req, res) {