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); }
//------------ 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(); } }
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"); } }
//------------ 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(); } }
//------------ 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(); } }
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"); } }
//------------ 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(); } }
//------------ 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(); } }
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"); } }
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"); } }
//------------ 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(); } }
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"); } } }
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"); } } }
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"); } } }
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"); } } }
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"); } } }
public IEnumerable <Administrator> getAllAdministrators() { PrescriptionContext db = new PrescriptionContext(); return(db.Administrators); }
public IEnumerable <Specialty> getAllSpecialties() { PrescriptionContext db = new PrescriptionContext(); return(db.Specialties); }
public IEnumerable <Prescription> getAllPrescriptions() { PrescriptionContext db = new PrescriptionContext(); return(db.Prescriptions); }
public IEnumerable <Doctor> getAllDoctors() { PrescriptionContext db = new PrescriptionContext(); return(db.Doctors); }
public IEnumerable <Patient> getAllPatients() { PrescriptionContext db = new PrescriptionContext(); return(db.Patients); }
public IEnumerable <Medicine> getAllMedicines() { PrescriptionContext db = new PrescriptionContext(); return(db.Medicines); }