public ActionResult Edit(newPacient data) { Doctor d = db.doctors.Where(t => t.ID == data.pacient.doctor.ID).First(); Pacient pc = db.pacients.Find(data.pacient.ID); if (d == null) { return(RedirectToAction("Index", "Pacients")); } //pc = data.pacient; //pc.doctor = dr; if (ModelState.IsValid) { pc.adress = data.pacient.adress; pc.birthday = data.pacient.birthday; pc.cart = data.pacient.cart; pc.comments = data.pacient.comments; pc.doctor = d; pc.father = data.pacient.father; pc.mother = data.pacient.mother; pc.name = data.pacient.name; pc.phone = data.pacient.phone; pc.sex = data.pacient.sex; db.SaveChanges(); } return(RedirectToAction("Details", new { id = pc.ID })); }
// GET: Pacients/Create public ActionResult Create() { newPacient na = new newPacient(); na.pacient = new Pacient(); na.doctors = db.doctors.ToList(); return(View(na)); }
// GET: Pacients/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Pacient pacient = db.pacients.Find(id); newPacient na = new newPacient(); na.pacient = pacient; if (pacient == null) { return(HttpNotFound()); } na.doctors = db.doctors.ToList(); return(View(na)); }
public ActionResult Create(newPacient data) { data.pacient.dateOfregistration = DateTime.Today; Doctor d = db.doctors.Where(t => t.ID == data.pacient.doctor.ID).First(); if (d == null) { return(RedirectToAction("Index", "Pacients")); } data.pacient.doctor = d; if (ModelState.IsValid) { db.pacients.Add(data.pacient); db.SaveChanges(); return(RedirectToAction("Details", new { id = data.pacient.ID })); } return(View(data)); }