Beispiel #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);
        }
Beispiel #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();
     }
 }
Beispiel #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");
            }
        }
Beispiel #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();
            }
        }
Beispiel #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();
            }
        }
Beispiel #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");
            }
        }
Beispiel #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();
            }
        }
Beispiel #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();
            }
        }
Beispiel #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");
            }
        }
Beispiel #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");
            }
        }
Beispiel #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();
            }
        }
Beispiel #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");
         }
     }
 }
Beispiel #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");
         }
     }
 }
Beispiel #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");
         }
     }
 }
Beispiel #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");
         }
     }
 }
Beispiel #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");
         }
     }
 }
Beispiel #17
0
        public IEnumerable <Administrator> getAllAdministrators()
        {
            PrescriptionContext db = new PrescriptionContext();

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

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

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

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

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

            return(db.Medicines);
        }