public List <Prescription> GetList() { using (var ctx = new PrescriptionDATA()) { return(ctx.Prescription.ToList()); } }
public void Add(List <MedicineTimes> medicines, Prescription prescription) { Doctor doctor = new Doctor(GetDoctor(prescription)); Patient patient = new Patient(GetPatient(prescription)); using (var ctx = new PrescriptionDATA()) { foreach (var item in medicines) { PrescriptionMedicine medicine = new PrescriptionMedicine(patient.TZ, item.MyMedicine.ProprietaryName, item.StartTime, item.EndTime); Prescription p = new Prescription(patient, doctor, medicine); ctx.Prescription.Add(p); ctx.SaveChanges(); } } }