public PatientViewModel(Patient patient) { IBL bl = new BLImplement(); Id = patient.Id; Name = patient.Name; PatientId = patient.PatientId; Prescriptions = bl.allPrescriptionFromPatient(patient).Select(p => p.Id).ToList(); }
// GET: Prescription public ActionResult Index(string id)//IEnumerable<Prescription> prescriptions) { IBL bl = new BLImplement(); var patient = bl.getPatient(id); if (patient == null) { patient = bl.getAllPatients().FirstOrDefault(X => X.Name == id);//when return to list } var prescriptions = bl.allPrescriptionFromPatient(patient); if (prescriptions == null) { ViewBag.Message = String.Format("There are no prescription for {0} yet", patient.Name); return(RedirectToAction("DoctorOptions")); } var lst = new List <PrescriptionViewModel>(); foreach (var item in prescriptions) { lst.Add(new PrescriptionViewModel(item)); } return(View(lst)); }