public ActionResult AddDrug(Drug drug) { if (ModelState.IsValid) { trackerDB.Patients.Find(drug.PatientId).Drugs.Add(drug); trackerDB.SaveChanges(); return RedirectToAction("Edit", new { id = drug.PatientId }); } populateDrugNames(1); return View(drug); }
public ActionResult EditDrug(Drug drug) { if (ModelState.IsValid) { trackerDB.Entry(drug).State = EntityState.Modified; trackerDB.SaveChanges(); return RedirectToAction("Edit", new { id = drug.PatientId }); } populateDrugNames(drug.DrugInfoId); return View(); }