public ActionResult Edit([Bind(Include = "id,doctor_id,patient_id,date,reason,result,treatment")] doctor_visits doctor_visits) { if (User.IsInRole("manager") || User.IsInRole("director")) { ; } else if (User.IsInRole("doctor")) { var user = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.FirstOrDefault(it => it.UserName == User.Identity.Name); int doctorId = DoctorsId.getDoctorId(user.Id); if (doctorId != doctor_visits.doctor_id) { return(RedirectToAction("Index")); } } if (ModelState.IsValid) { db.Entry(doctor_visits).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.doctor_id = new SelectList(db.doctors, "id", "FIO", doctor_visits.doctor_id); ViewBag.patient_id = new SelectList(db.patients, "id", "FIO", doctor_visits.patient_id); return(View(doctor_visits)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } doctor_visits doctor_visits = db.doctor_visits.Find(id); if (User.IsInRole("manager") || User.IsInRole("director")) { ; } else if (User.IsInRole("doctor")) { var user = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.FirstOrDefault(it => it.UserName == User.Identity.Name); int doctorId = DoctorsId.getDoctorId(user.Id); if (doctorId != doctor_visits.doctor_id) { return(RedirectToAction("Index")); } } if (doctor_visits == null) { return(HttpNotFound()); } ViewBag.doctor_id = new SelectList(db.doctors, "id", "FIO", doctor_visits.doctor_id); ViewBag.patient_id = new SelectList(db.patients, "id", "FIO", doctor_visits.patient_id); return(View(doctor_visits)); }
public ActionResult DeleteConfirmed(int id) { doctor_visits doctor_visits = db.doctor_visits.Find(id); db.doctor_visits.Remove(doctor_visits); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create() { ViewBag.doctor_id = new SelectList(db.doctors.Where((it) => it.date_end_work == null), "id", "FIO"); ViewBag.patient_id = new SelectList(db.patients, "id", "FIO"); doctor_visits doctor_visits = new doctor_visits(); doctor_visits.date = DateTime.Now; return(View()); }
public ActionResult Create([Bind(Include = "id,doctor_id,patient_id,date,reason,result,treatment")] doctor_visits doctor_visits) { if (ModelState.IsValid) { db.doctor_visits.Add(doctor_visits); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.doctor_id = new SelectList(db.doctors, "id", "FIO", doctor_visits.doctor_id); ViewBag.patient_id = new SelectList(db.patients, "id", "FIO", doctor_visits.patient_id); return(View(doctor_visits)); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } doctor_visits doctor_visits = db.doctor_visits.Find(id); if (doctor_visits == null) { return(HttpNotFound()); } return(View(doctor_visits)); }