aboutsummaryrefslogtreecommitdiff
path: root/interface/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'interface/controllers')
-rw-r--r--interface/controllers/citizens.controller.js26
-rw-r--r--interface/controllers/district.controller.js19
-rw-r--r--interface/controllers/mandal.controller.js16
-rw-r--r--interface/controllers/state.controller.js13
-rw-r--r--interface/controllers/village.controller.js18
5 files changed, 92 insertions, 0 deletions
diff --git a/interface/controllers/citizens.controller.js b/interface/controllers/citizens.controller.js
index ee9355b..0ee1d42 100644
--- a/interface/controllers/citizens.controller.js
+++ b/interface/controllers/citizens.controller.js
@@ -15,6 +15,15 @@ exports.findXCitizens = () => {
return sequelize.query(query, { type: QueryTypes.SELECT })
};
+
+exports.deleteCitizenbyId = (citizen_id) =>{
+
+ return citizens.destroy({
+ where: { citizen_id }
+ })
+
+};
+
exports.editCitizen = (citizen_id, address, mobile_num, dob, marital_status) => {
return citizens.update({
address, mobile_num, dob, marital_status
@@ -25,6 +34,23 @@ exports.editCitizen = (citizen_id, address, mobile_num, dob, marital_status) =>
});
};
+//Check Citizen exists or not
+exports.checkCitizenId = (citizen_id) => {
+ return citizens.findOne({
+ where: {
+ citizen_id
+ }
+ }).then(
+ citizen_id => {
+ if (citizen_id) {
+ return true;
+ }
+ return false;
+ }
+ )
+}
+
+
// Get total number of male and female citizens
exports.findGenderDistribution = () => {
// group by the 'gender' column
diff --git a/interface/controllers/district.controller.js b/interface/controllers/district.controller.js
new file mode 100644
index 0000000..5b21530
--- /dev/null
+++ b/interface/controllers/district.controller.js
@@ -0,0 +1,19 @@
+const db = require("../models");
+const district = db.district_master;
+
+exports.allDistricts = () => {
+ return district.findAll({
+ attributes: ['district_id', 'district_name']
+ })
+};
+
+
+exports.allDistrictsByStateId = (state_id) => {
+ const query =`SELECT * FROM district_master WHERE state_id = ${state_id}`;
+ return db.sequelize.query(query, { type: db.sequelize.QueryTypes.SELECT });
+};
+
+
+
+
+
diff --git a/interface/controllers/mandal.controller.js b/interface/controllers/mandal.controller.js
new file mode 100644
index 0000000..43842fe
--- /dev/null
+++ b/interface/controllers/mandal.controller.js
@@ -0,0 +1,16 @@
+const db = require("../models");
+const mandal = db.mandal_master;
+
+
+exports.allMandals = () => {
+ return mandal.findAll({
+ attributes: ['mandal_id', 'mandal_name']
+ })
+};
+
+
+exports.allMandalsByDistrictId = (district_id) => {
+ const query =`SELECT * FROM mandal_master WHERE district_id = ${district_id}`;
+ return db.sequelize.query(query, { type: db.sequelize.QueryTypes.SELECT });
+
+};
diff --git a/interface/controllers/state.controller.js b/interface/controllers/state.controller.js
new file mode 100644
index 0000000..1a3a4ed
--- /dev/null
+++ b/interface/controllers/state.controller.js
@@ -0,0 +1,13 @@
+const db = require("../models");
+const state = db.state_master;
+
+// function to get all states
+exports.allStates = () => {
+ const query = "SELECT * FROM state_master";
+ return db.sequelize.query(query, { type: db.sequelize.QueryTypes.SELECT });
+
+};
+
+
+
+
diff --git a/interface/controllers/village.controller.js b/interface/controllers/village.controller.js
new file mode 100644
index 0000000..0a488d4
--- /dev/null
+++ b/interface/controllers/village.controller.js
@@ -0,0 +1,18 @@
+const db = require("../models");
+const village = db.village_master;
+
+
+exports.allVillages = () => {
+ return village.findAll({
+ attributes: ['village_id', 'village_name']
+ })
+};
+
+
+exports.allVillagesByMandalId = (mandal_id) => {
+ const query =`SELECT * FROM village_master WHERE mandal_id = ${mandal_id}`;
+ return db.sequelize.query(query, { type: db.sequelize.QueryTypes.SELECT });
+
+};
+
+