public ActionResult Edit(AppointmentEditViewModel viewModel) { var appointment = viewModel.Appointment; if (ModelState.IsValid) { db.Entry(appointment).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("AppointmentList"); } return View(viewModel); }
// GET: Appointments/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Appointment appointment = db.Appointments.Find(id); if (appointment == null) { return HttpNotFound(); } var vm = new AppointmentEditViewModel() { Appointment = appointment }; if (User.IsInRole("Doctor")) vm.ControllerName = "AppointmentList"; if (User.IsInRole("Patient")) vm.ControllerName = "PatientAppointmentList"; if (User.IsInRole("Admin")) vm.ControllerName = "AdminAppointmentList"; return View(vm); }