public ActionResult Edit([Bind(Include = "id,attending_doctor_id,patient_id,date_start,date_end,reason,treatment")] placing_in_hospital placing_in_hospital) { 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 != placing_in_hospital.attending_doctor_id) { return(RedirectToAction("Index")); } } if (ModelState.IsValid) { db.Entry(placing_in_hospital).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.attending_doctor_id = new SelectList(db.doctors, "id", "FIO", placing_in_hospital.attending_doctor_id); ViewBag.patient_id = new SelectList(db.patients, "id", "FIO", placing_in_hospital.patient_id); return(View(placing_in_hospital)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } placing_in_hospital placing_in_hospital = db.placing_in_hospital.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 != placing_in_hospital.attending_doctor_id) { return(RedirectToAction("Index")); } } if (placing_in_hospital == null) { return(HttpNotFound()); } ViewBag.attending_doctor_id = new SelectList(db.doctors, "id", "FIO", placing_in_hospital.attending_doctor_id); ViewBag.patient_id = new SelectList(db.patients, "id", "FIO", placing_in_hospital.patient_id); return(View(placing_in_hospital)); }
public ActionResult DeleteConfirmed(int id) { placing_in_hospital placing_in_hospital = db.placing_in_hospital.Find(id); db.placing_in_hospital.Remove(placing_in_hospital); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create() { ViewBag.attending_doctor_id = new SelectList(db.doctors.Where((it) => it.date_end_work == null), "id", "FIO"); ViewBag.patient_id = new SelectList(db.patients, "id", "FIO"); placing_in_hospital placing_in_hospital = new placing_in_hospital(); placing_in_hospital.date_start = DateTime.Now; return(View(placing_in_hospital)); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } placing_in_hospital placing_in_hospital = db.placing_in_hospital.Find(id); if (placing_in_hospital == null) { return(HttpNotFound()); } return(View(placing_in_hospital)); }
public ActionResult Create([Bind(Include = "id,attending_doctor_id,patient_id,date_start,date_end,reason,treatment")] placing_in_hospital placing_in_hospital) { if (ModelState.IsValid) { try { db.placing_in_hospital.Add(placing_in_hospital); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.InnerException != null) { var mess = ex.InnerException.InnerException.Message; ViewData["error"] = mess.Substring(0, mess.Length > 65 ? mess.Length - 65 : mess.Length); } } } ViewBag.attending_doctor_id = new SelectList(db.doctors, "id", "FIO", placing_in_hospital.attending_doctor_id); ViewBag.patient_id = new SelectList(db.patients, "id", "FIO", placing_in_hospital.patient_id); return(View(placing_in_hospital)); }