public ActionResult Confirm(DoctorForm form) { return form.Doctor == null ? RedirectTo<DoctorController>(a => a.List()) : View(form); }
public ActionResult Edit(int? id, DoctorForm form) { if (!id.HasValue) return RedirectTo<DoctorController>(a => a.List()); form.Doctor = form.Doctor ?? Get<IDoctorRepository>().GetById(id.Value); if (form.Doctor == null) return RedirectTo<DoctorController>(a => a.List()); form.Specialties = DIKernel.Get<ISpecialtyRepository>().GetAll(); return View(form); }
public ActionResult AddSubmit(DoctorForm form) { if (ModelState.IsValid) { Get<IDoctorRepository>().Save(form.Doctor); form.Message = "Доктор добавлен"; return RedirectTo<DoctorController>(a => a.Confirm(form)); } return RedirectTo<DoctorController>(a => a.Add(form)); }
public ActionResult Delete(int? id, bool? confirm) { if (!id.HasValue) return RedirectTo<DoctorController>(a => a.List()); if (!confirm.HasValue) { Doctor doctor = Get<IDoctorRepository>().GetById(id.Value); if (doctor == null) return RedirectTo<DoctorController>(a => a.List()); var form = new DoctorForm { Doctor = doctor }; return View(form); } if (confirm.Value) DIKernel.Get<IDoctorRepository>().DeleteById(id.Value); return RedirectTo<DoctorController>(a => a.List()); }
public ActionResult Edit(DoctorForm form) { if (ModelState.IsValid) { Get<IDoctorRepository>().Update(form.Doctor); form.Message = "Информация о докторе изменена"; return RedirectTo<DoctorController>(a => a.Confirm(form)); } return RedirectTo<DoctorController>(a => a.Edit(form.Doctor.Id, form)); }
public ActionResult Add(DoctorForm form) { form.Specialties = Get<ISpecialtyRepository>().GetAll(); return View(form); }
public ActionResult Show(int? id) { if (!id.HasValue) return RedirectTo<DoctorController>(a => a.List()); Doctor doctor = Get<IDoctorRepository>().GetById(id.Value); if (doctor == null) return RedirectTo<DoctorController>(a => a.List()); var form = new DoctorForm { Doctor = doctor }; return View(form); }