Rag2ey / child2

0 stars 0 forks source link

found_child #2

Open Rag2ey opened 6 months ago

Rag2ey commented 6 months ago

class found_child { constructor(child_name, child_age, child_gender, health_state, way_of_found, lost_before, child_clothes, child_mark, governorate_of_found, city_of_found, address_of_found,current_government, current_city, current_address,volunteer_full_name, volunteer_phone_number, volunteer_address,volunteer_national_id,gender, record_number) { this.child_name = child_name; this.child_age = child_age; this.child_gender = child_gender; this.health_state = health_state; this.way_of_found = way_of_found; this.lost_before = lost_before; this.child_clothes = child_clothes; this.child_mark = child_mark; this.governorate_of_found = governorate_of_found; this.city_of_found = city_of_found; this.address_of_found = address_of_found; this.current_government = current_government; this.current_city = current_city; this.current_address = current_address; this.volunteer_full_name = volunteer_full_name; this.volunteer_phone_number = p volunteer_phone_number; this.volunteer_address = volunteer_address; this.volunteer_national_id = volunteer_national_id; this.gender = gender; this.record_number = record_number;

}
Rag2ey commented 5 months ago

class lab { constructor(name, email, address, phone_number, free_reservations_available, rooms_available, time_slot) { this.name = name; this.email = email; this.address = address; this.phone_number = phone_number; this.free_reservations_available = free_reservations_available; this.rooms_available = rooms_available; this.time_slot = time_slot; } }

Rag2ey commented 5 months ago

class user { constructor(name, email, address, phone_number, Reason_for_reservation, position, time_slot) { this.name = name; this.email = email; this.address = address; this.phone_number = phone_number; this.Reason_for_reservation = Reason_for_reservation; this.position = position; this.time_slot = time_slot; } }

Rag2ey commented 5 months ago

class ReservationModel { constructor(name, email, address, phone_number, Reason_for_reservation, age, gender ,available_rooms) { this.name = name; this.email = email; this.address = address; this.phone_number = phone_number; this.Reason_for_reservation = Reason_for_reservation; this. age = age; this.gender = gender; this.available_rooms = available_rooms;

} async save(){ try{ const ReservationcaseRef = await db.firestore().collection('Reservation_case').add({ name: this.name, email:this.email, address:this.address, phone_number:this.phone_number, Reason_for_reservation:this.Reason_for_reservation, age:this.age, gender:this.gender, available_rooms:this.available_rooms, }); console.log(Reservation user created with ${ReservationcaseRef.id}); return ReservationcaseRef.id } catch (error){ console.error('error creating user',error); throw error; } } } module.exports=ReservationModel;

Rag2ey commented 5 months ago

const ReservationModel = require('../models/ReservationModel'); const ReservationModel = require('./ReservationModel'); module.exports.post = async(req,res) => { try { const data=[req.body.name, req.body.email, req.body.address, req.body.phone_number, req.body.Reason_for_reservation, req.body.age, req.body.gender, req.body.available_rooms];

    console.log(data);

  const newcase = new ReservationModel(...data);

  newcase.save()
.then(caseId => {
  return res.send(`case created with ID :${caseId}`);

})
} catch (err) {
  return res.status(500).send({
    error: err.message
  });
}

}; module.exports.put = async (req, res) => { try { const caseId = req.params.id; console.log(caseId); const newData = req.body; const ReservationModel = new ReservationModel(); await ReservationModel.update(caseId, newData);

return res.json({ message: `case with ID ${caseId} updated` });

} catch (error) { console.error('Error updating case:', error); return res.status(500).json({ error: 'Internal server Error' }); } }; module.exports.delete = async (req, res) => { try { const caseId = req.params.id; const ReservationModel = new ReservationModel(); await ReservationModel.delete(caseId);

return res.json({ message:`case with ID ${caseId} deleted` });

} catch (error) { console.error('Error updating case:', error); return res.status(500).json({ error: 'Internal Server Error' }); } };
module.exports.getAllcases = async(req, res) => { try{ const ReservationModel= new ReservationModel(); const allcases= await ReservationModel.getAllcases();

 return res.json({ cases: allcases});

}catch (error) { console.error('Error getting all cases:', error); return res.status(500).json({ error: 'Internal Server Error' }); } };

Rag2ey commented 5 months ago

const {Router} = require('express');

const ReservationController = require('../controllers/ReservationController'); const ReservationRouter= Router(); ReservationRouter.post('/createCase',ReservationController.post); ReservationRouter.put('/updateCase/:id',ReservationController.put); ReservationRouter.delete('/deletecase/:id',ReservationController.delete); ReservationRouter.get('/getAllCases',ReservationController.getAllCases); ReservationRouter.get('/getCaseById/:id',ReservationController.getCaseById);

module.exports =ReservationRouter;

Rag2ey commented 5 months ago

class ReservationModel { constructor(name, email, address, phone_number, Reason_for_reservation, age, gender ,available_rooms) { this.name = name; this.email = email; this.address = address; this.phone_number = phone_number; this.Reason_for_reservation = Reason_for_reservation; this. age = age; this.gender = gender; this.available_rooms = available_rooms;

} async save(){ try{ const ReservationcaseRef = await db.firestore().collection('Reservation_case').add({ name: this.name, email:this.email, address:this.address, phone_number:this.phone_number, Reason_for_reservation:this.Reason_for_reservation, age:this.age, gender:this.gender, available_rooms:this.available_rooms, }); console.log(Reservation case created with ${ReservationcaseRef.id}); return ReservationcaseRef.id } catch (error){ console.error('error creating case',error); throw error; } } async update(caseId, newData) { try { await db.firestore().collection('Reservation_case').doc(caseId).update(newData); console.log(case with ID ${caseId} updated); } catch (error) { console.error('Error updating case:', error); throw error; } } async delete(caseId) { try { await db.firestore().collection('Reservation_case').doc(caseId).delete(); console.log(case with ID ${caseId} deleted); } catch (error) { console.error('Error deleting case:', error); throw error; } } async getAllCases(){ try{ const caseCollection = await db.firestore().collection('Reservation_case').get(); const allCases= caseCollection.docs.map(doc => ({ id:doc.id, ...doc.data() })); return allCases; } catch(error){ console.error('Error getting all cases:', error); throw error; } } async get(caseId){ try { const caseSnapshot =await db.firestore().collection('Reservation_case').doc(caseId).get(); if (!caseSnapshot.exists) { throw new Error(case with ID ${caseId} not found); } const Case ={ id: caseSnapshot.id, ...caseSnapshot.data(), } return Case;

} catch (error) {
  console.error('Error getting case:', error);
  throw error;
}

} } module.exports = ReservationModel;

Rag2ey commented 5 months ago

class LabModel { constructor(name, email, address, phone_number, free_reservations_available, branches, nearest_lab, emergency_number) { this.name = name; this.email = email; this.address = address; this.phone_number = phone_number; this.free_reservations_available = free_reservations_available; this.branches = branches; this.nearest_lab = nearest_lab; this.emergency_number = emergency_number;

} async save() { try { const LabCaseRef = await db.firestore().collection('Lab_case').add({ name: this.name, email: this.email, address: this.address, phone_number: this.phone_number, free_reservations_available: this.free_reservations_available, branches: this.branches, nearest_lab: this.nearest_lab, emergency_number: this.emergency_number,

  });
  console.log(`Lab case created with ${LabcaseRef.id}`);
  return LabcaseRef.id 
} catch (error){
  console.error('error creating case',error);
  throw error;
}

} async update(caseId, newData) { try { await db.firestore().collection('Lab_case').doc(caseId).update(newData); console.log(case with ID ${caseId} updated); } catch (error) { console.error('Error updating case:', error); throw error; } } async delete(caseId) { try { await db.firestore().collection('Lab_case').doc(caseId).delete(); console.log(case with ID ${caseId} deleted); } catch (error) { console.error('Error deleting case:', error); throw error; } } async getAllCases(){ try{ const caseCollection = await db.firestore().collection('Lab_case').get(); const allCases= caseCollection.docs.map(doc => ({ id:doc.id, ...doc.data() })); return allCases; } catch(error){ console.error('Error getting all cases:', error); throw error; } } async get(caseId){ try { const caseSnapshot =await db.firestore().collection('Lab_case').doc(caseId).get(); if (!caseSnapshot.exists) { throw new Error(case with ID ${caseId} not found); } const Case ={ id: caseSnapshot.id, ...caseSnapshot.data(), } return Case;

} catch (error) {
  console.error('Error getting case:', error);
  throw error;
}

} } module.exports = LabModel;

Rag2ey commented 5 months ago

const LabModel = require('../models//LabModel'); const LabModel = require('./LabModel'); module.exports.post = async(req,res) => { try { const data=[req.body.name, req.body.email, req.body.address, req.body.phone_number, req.body.free_reservations_available, req.body.branches, req.body.nearest_lab, req.body.emergency_number];

    console.log(data);

  const newcase = new LabModel(...data);

  newcase.save()
.then(caseId => {
  return res.send(`case created with ID :${caseId}`);

})
} catch (err) {
  return res.status(500).send({
    error: err.message
  });
}

}; module.exports.put = async (req, res) => { try { const caseId = req.params.id; console.log(caseId); const newData = req.body; const LabModel = new LabModel(); await LabModel.update(caseId, newData);

return res.json({ message: `case with ID ${caseId} updated` });

} catch (error) { console.error('Error updating case:', error); return res.status(500).json({ error: 'Internal server Error' }); } }; module.exports.delete = async (req, res) => { try { const caseId = req.params.id; const LabModel = new LabModel(); await LabModel.delete(caseId);

return res.json({ message:`case with ID ${caseId} deleted` });

} catch (error) { console.error('Error updating case:', error); return res.status(500).json({ error: 'Internal Server Error' }); } };
module.exports.getAllcases = async(req, res) => { try{ const LabModel= new LabModel(); const allcases= await LabModel.getAllcases();

 return res.json({ cases: allcases});

}catch (error) { console.error('Error getting all cases:', error); return res.status(500).json({ error: 'Internal Server Error' }); } };

Rag2ey commented 5 months ago

const {Router} = require('express');

const LabController = require('../controllers/LabController'); const LabRouter= Router(); LabRouter.post('/createCase',LabController.post); LabRouter.put('/updateCase/:id',LabController.put); LabRouter.delete('/deletecase/:id',LabController.delete); LabRouter.get('/getAllCases',LabController.getAllCases); LabRouter.get('/getCaseById/:id',LabController.getCaseById);

module.exports =LabRouter;

Rag2ey commented 5 months ago

class dnaModel { constructor( patient_name, patient_age, patient_result, patient_type, patient_gender, patient_sequence, patient_number, patient_image) { this.patient_name = patient_name; this.patient_age = patient_age; this.patient_result = patient_result; this.patient_type = patient_type; this.patient_gender = patient_gender; this.patient_sequence = patient_sequence; this.patient_number = patient_number; this.patient_image = patient_image;

} async save(){ try{ const dnacaseRef = await db.firestore().collection('dna_case').add({ patient_name: this.patient_name, patient_age: this.patient_age, patient_result: this.patient_result, patient_type: this.patient_type, patient_gender: this.patient_gender, patient_sequence: this.patient_sequence, patient_number: this.patient_number, patient_image: this.patient_image, }); console.log(dna case created with ${dnacaseRef.id}); return dnacaseRef.id } catch (error){ console.error('error creating case',error); throw error; } } async update(caseId, newData) { try { await db.firestore().collection('dna_case').doc(caseId).update(newData); console.log(case with ID ${caseId} updated); } catch (error) { console.error('Error updating case:', error); throw error; } } async delete(caseId) { try { await db.firestore().collection('dna_case').doc(caseId).delete(); console.log(case with ID ${caseId} deleted); } catch (error) { console.error('Error deleting case:', error); throw error; } } async getAllCases(){ try{ const caseCollection = await db.firestore().collection('dna_case').get(); const allCases= caseCollection.docs.map(doc => ({ id:doc.id, ...doc.data() })); return allCases; } catch(error){ console.error('Error getting all cases:', error); throw error; } } async get(caseId){ try { const caseSnapshot =await db.firestore().collection('dna_case').doc(caseId).get(); if (!caseSnapshot.exists) { throw new Error(case with ID ${caseId} not found); } const Case ={ id: caseSnapshot.id, ...caseSnapshot.data(), } return Case;

} catch (error) {
  console.error('Error getting case:', error);
  throw error;
}

} } module.exports = dnaModel;

Rag2ey commented 5 months ago

const dnaModel = require('../models/dnaModel'); const dnaModel = require('./dnaModel'); module.exports.post = async(req,res) => { try { const data=[req.body.patient_name, req.body.patient_age, req.body.patient_result, req.body.patient_type, req.body.patient_gender, req.body.patient_sequence, req.body.patient_number, req.body.patient_image];

    console.log(data);

  const newcase = new dnaModel(...data);

  newcase.save()
.then(caseId => {
  return res.send(`case created with ID :${caseId}`);

})
} catch (err) {
  return res.status(500).send({
    error: err.message
  });
}

}; module.exports.put = async (req, res) => { try { const caseId = req.params.id; console.log(caseId); const newData = req.body; const dnaModel = new dnaModel(); await dnaModel.update(caseId, newData);

return res.json({ message: `case with ID ${caseId} updated` });

} catch (error) { console.error('Error updating case:', error); return res.status(500).json({ error: 'Internal server Error' }); } }; module.exports.delete = async (req, res) => { try { const caseId = req.params.id; const dnaModel = new dnaModel(); await dnaModel.delete(caseId);

return res.json({ message:`case with ID ${caseId} deleted` });

} catch (error) { console.error('Error updating case:', error); return res.status(500).json({ error: 'Internal Server Error' }); } };
module.exports.getAllcases = async(req, res) => { try{ const dnaModel= new dnaModel(); const allcases= await dnaModel.getAllcases();

 return res.json({ cases: allcases});

}catch (error) { console.error('Error getting all cases:', error); return res.status(500).json({ error: 'Internal Server Error' }); } };

Rag2ey commented 5 months ago

const {Router} = require('express');

const dnaController = require('../controllers/dnaController'); const dnaRouter= Router(); dnaRouter.post('/createCase',dnaController.post); dnaRouter.put('/updateCase/:id',dnaController.put); dnaRouter.delete('/deletecase/:id',dnaController.delete); dnaRouter.get('/getAllCases',dnaController.getAllCases); dnaRouter.get('/getCaseById/:id',dnaController.getCaseById);

module.exports =dnaRouter;