public ActionResult Create(DoctorAppointmentStatus doctorAppointmentStatus) { if (ModelState.IsValid) { db.DoctorAppointmentStatuses.Add(doctorAppointmentStatus); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.VetId = new SelectList(db.Vets, "Id", "Name", doctorAppointmentStatus.Doctor.VetId); return View(doctorAppointmentStatus); }
// // GET: /DoctorAppointmentStatus/ public ActionResult Index() { var vet = db.Vets.SingleOrDefault(r => r.Username == HttpContext.User.Identity.Name); var doctors = db.Doctors.Where(r => r.VetId == vet.Id); using (var _db = new FnRDbContext()) { foreach (var doctor in doctors) { if (doctor != null) { var doctorForAppointmet = new DoctorAppointmentStatus { DoctorId = doctor.Id, ExpectedWaitTime = 0, ExpectedDurationOfDelay = 0 }; if (!_db.DoctorAppointmentStatuses.Where(r => r.DoctorId == doctorForAppointmet.DoctorId).Any()) { _db.DoctorAppointmentStatuses.Add(doctorForAppointmet); _db.SaveChanges(); } } } } var doctorAppointmentStatuses = db.DoctorAppointmentStatuses.Include(d => d.Doctor.Vet).Where(r => r.Doctor.VetId == vet.Id); return View(doctorAppointmentStatuses.ToList()); }
public ActionResult Edit(DoctorAppointmentStatus doctorAppointmentStatus) { if (ModelState.IsValid) { db.Entry(doctorAppointmentStatus).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.VetId = new SelectList(db.Vets, "Id", "Name", doctorAppointmentStatus.Doctor.VetId); return View(doctorAppointmentStatus); }