public ActionResult prescriptionIssuance(FormCollection collection)///*string medicine*/, DateTime StartDate, DateTime EndDate, string Doctor, string Patient, string Cause) { try { IBL bl = new BLImplement(); Prescription prescription = new Prescription() { medicine = bl.getAllMedicines().FirstOrDefault(x => x.Name == collection["medicine"]).Id,//change the name to the id StartDate = Convert.ToDateTime(collection["StartDate"]), EndDate = Convert.ToDateTime(collection["EndDate"]), Doctor = collection["Doctor"], Patient = collection["Patient"], Cause = collection["prescription.Cause"] }; bl.addPrescription(prescription); ViewBag.Message = String.Format("The prescription for {0} is successfully added. You can watch {1}'s medical history for full details. ", collection["medicine"].ToString(), bl.getPatient(prescription.Patient).Name.ToString()); return(RedirectToAction("DoctorOptions" /*, prescription.Doctor*/)); } catch (Exception ex) { ViewBag.Message = String.Format(ex.Message); return(RedirectToAction("prescriptionIssuance")); } }