Exemplo n.º 1
0
        public List <int> info(string medicineName, int year)
        {
            PrescriptionContext db    = new PrescriptionContext();
            List <int>          month = new List <int> {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };
            List <Prescription> pres = new List <Prescription>();

            foreach (Prescription item in db.Prescriptions)
            {
                var a = this.getAllMedicines().FirstOrDefault(x => x.Id == item.medicine);
                if (a != null && a.Name == medicineName)
                {
                    pres.Add(item);
                }
            }
            foreach (var item in pres)
            {
                if (item.StartDate.Year == year)
                {
                    month[item.StartDate.Month - 1]++;
                }
            }
            return(month);
        }
Exemplo n.º 2
0
 //------------ Administrators ---------------
 public void addAdministrator(Administrator administrator)
 {
     PrescriptionContext db = new PrescriptionContext();
     //if (db.Administrators.ToList().Exists(admin => admin.Id == administrator.Id))
     //{
     //    throw new Exception("This administrator exists already");
     //}
     //else
     {
         db.Administrators.Add(administrator);
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
        public void updateMedicine(Medicine medicine)
        {
            PrescriptionContext db = new PrescriptionContext();

            if (db.Medicines.ToList().Exists(mdn => mdn.Id == medicine.Id))
            {
                db.Medicines.AddOrUpdate(medicine);
                db.SaveChanges();
            }
            else
            {
                throw new Exception("This medicine does not exist");
            }
        }
Exemplo n.º 4
0
        //------------ Medicines ---------------
        public void addMedicine(Medicine medicine)
        {
            PrescriptionContext db = new PrescriptionContext();

            if (db.Medicines.ToList().Exists(mdn => mdn.Id == medicine.Id))
            {
                throw new Exception("This medicine exists already");
            }
            else
            {
                db.Medicines.Add(medicine);
                db.SaveChanges();
            }
        }
Exemplo n.º 5
0
        //------------ Prescriptions ---------------
        public void addPrescription(Prescription prescription)
        {
            PrescriptionContext db = new PrescriptionContext();

            if (db.Prescriptions.ToList().Exists(prs => prs.Id == prescription.Id))
            {
                throw new Exception("This prescription exsits already");
            }
            else
            {
                db.Prescriptions.Add(prescription);
                db.SaveChanges();
            }
        }
Exemplo n.º 6
0
        public void updateDoctor(Doctor doctor)
        {
            PrescriptionContext db = new PrescriptionContext();

            if (db.Doctors.ToList().Exists(doc => doc.DoctorId == doctor.DoctorId))
            {
                db.Doctors.AddOrUpdate(doctor);
                db.SaveChanges();
            }
            else
            {
                throw new Exception("This doctor does not exist");
            }
        }
Exemplo n.º 7
0
        //------------ Specialties ---------------
        public void addSpecialty(Specialty specialty)
        {
            PrescriptionContext db = new PrescriptionContext();

            if (db.Specialties.ToList().Exists(spc => spc.Id == specialty.Id))
            {
                throw new Exception("This specialty exsits already");
            }
            else
            {
                db.Specialties.Add(specialty);
                db.SaveChanges();
            }
        }
Exemplo n.º 8
0
        //------------ Doctors ---------------
        public void addDoctor(Doctor doctor)
        {
            PrescriptionContext db = new PrescriptionContext();

            if (db.Doctors.ToList().Exists(doc => doc.DoctorId == doctor.DoctorId))
            {
                throw new Exception("This doctor exists already");
            }
            else
            {
                db.Doctors.Add(doctor);
                db.SaveChanges();
            }
        }
Exemplo n.º 9
0
        public void updateAdministrator(Administrator administrator)
        {
            PrescriptionContext db = new PrescriptionContext();

            if (db.Administrators.ToList().Exists(admin => admin.Id == administrator.Id))
            {
                db.Administrators.AddOrUpdate(administrator);
                db.SaveChanges();
            }
            else
            {
                throw new Exception("This administrator does not exist");
            }
        }
Exemplo n.º 10
0
        public void updatePatient(Patient patient)
        {
            PrescriptionContext db = new PrescriptionContext();

            if (db.Patients.ToList().Exists(pt => pt.PatientId == patient.PatientId))
            {
                db.Patients.AddOrUpdate(patient);
                db.SaveChanges();
            }
            else
            {
                throw new Exception("This patient does not exist");
            }
        }
Exemplo n.º 11
0
        //------------ Patients ---------------
        public void addPatient(Patient patient)
        {
            PrescriptionContext db = new PrescriptionContext();

            if (db.Patients.ToList().Exists(pt => pt.PatientId == patient.PatientId))
            {
                throw new Exception("This patient exists already");
            }
            else
            {
                db.Patients.Add(patient);
                db.SaveChanges();
            }
        }
Exemplo n.º 12
0
 public void deleteDoctor(Doctor doctor)
 {
     using (var context = new PrescriptionContext())
     {
         if (context.Doctors.ToList().Exists(doc => doc.DoctorId == doctor.DoctorId))
         {
             var deletedDoctor = context.Doctors.Where(doc => doc.DoctorId == doctor.DoctorId).FirstOrDefault();
             context.Doctors.Remove(deletedDoctor);
             context.SaveChanges();
         }
         else
         {
             throw new Exception("This doctor does not exist");
         }
     }
 }
Exemplo n.º 13
0
 public void deleteAdministrator(Administrator administrator)
 {
     using (var context = new PrescriptionContext())
     {
         if (context.Administrators.ToList().Exists(admin => admin.Id == administrator.Id))
         {
             var deletedAdministrator = context.Administrators.Where(a => a.Id == administrator.Id).FirstOrDefault();
             context.Administrators.Remove(deletedAdministrator);
             context.SaveChanges();
         }
         else
         {
             throw new Exception("This administrator does not exist");
         }
     }
 }
Exemplo n.º 14
0
 public void deleteSpecialty(Specialty specialty)
 {
     using (var context = new PrescriptionContext())
     {
         if (context.Specialties.ToList().Exists(s => s.Id == specialty.Id))
         {
             var deletedSpecialty = context.Specialties.Where(pt => pt.Id == specialty.Id).FirstOrDefault();
             context.Specialties.Remove(deletedSpecialty);
             context.SaveChanges();
         }
         else
         {
             throw new Exception("This patient does not exist");
         }
     }
 }
Exemplo n.º 15
0
 public void deletePatient(Patient patient)
 {
     using (var context = new PrescriptionContext())
     {
         if (context.Patients.ToList().Exists(pt => pt.PatientId == patient.PatientId))
         {
             var deletedPatient = context.Patients.Where(pt => pt.PatientId == patient.PatientId).FirstOrDefault();
             context.Patients.Remove(deletedPatient);
             context.SaveChanges();
         }
         else
         {
             throw new Exception("This patient does not exist");
         }
     }
 }
Exemplo n.º 16
0
 public void deleteMedicine(Medicine medicine)
 {
     using (var context = new PrescriptionContext())
     {
         if (context.Medicines.ToList().Exists(mdn => mdn.Id == medicine.Id))
         {
             var deletedMedicine = context.Medicines.Where(m => m.Id == medicine.Id).FirstOrDefault();
             context.Medicines.Remove(deletedMedicine);
             context.SaveChanges();
             GoogleDriveAPIHelper gd = new GoogleDriveAPIHelper();
             gd.deleteFile(medicine.Id.ToString());
         }
         else
         {
             throw new Exception("This medicine does not exist");
         }
     }
 }
Exemplo n.º 17
0
        public IEnumerable <Administrator> getAllAdministrators()
        {
            PrescriptionContext db = new PrescriptionContext();

            return(db.Administrators);
        }
Exemplo n.º 18
0
        public IEnumerable <Specialty> getAllSpecialties()
        {
            PrescriptionContext db = new PrescriptionContext();

            return(db.Specialties);
        }
Exemplo n.º 19
0
        public IEnumerable <Prescription> getAllPrescriptions()
        {
            PrescriptionContext db = new PrescriptionContext();

            return(db.Prescriptions);
        }
Exemplo n.º 20
0
        public IEnumerable <Doctor> getAllDoctors()
        {
            PrescriptionContext db = new PrescriptionContext();

            return(db.Doctors);
        }
Exemplo n.º 21
0
        public IEnumerable <Patient> getAllPatients()
        {
            PrescriptionContext db = new PrescriptionContext();

            return(db.Patients);
        }
Exemplo n.º 22
0
        public IEnumerable <Medicine> getAllMedicines()
        {
            PrescriptionContext db = new PrescriptionContext();

            return(db.Medicines);
        }