Ejemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "Id,Duration,Start,End,Date,DoctorId,FacilityId,ForeignDoctorServiceId")] DoctorSchedule doctorSchedule)
        {
            if (ModelState.IsValid)
            {
                var schedule = repo.GetByIdAsNonTracking(doctorSchedule.Id);
                scheduleManager.DeleteSlots(schedule, schedule.DoctorFacility);

                repo.Update(doctorSchedule);
                repo.Save();



                scheduleManager.PushSlots(repo.GetById(doctorSchedule.Id).DoctorFacility);

                return(RedirectToAction("Index"));
            }

            var doctorFacilities = doctorFacilityRepo.GetAll();

            ViewBag.DoctorId               = new SelectList(facilityRepo.GetDoctors(doctorSchedule.FacilityId), "Id", "Name", doctorSchedule.DoctorId);
            ViewBag.FacilityId             = new SelectList(doctorFacilityRepo.GetAllFacilities(), "Id", "Name", doctorSchedule.FacilityId);
            ViewBag.ForeignDoctorServiceId = doctorServiceRepo.GetAll();

            return(View(doctorSchedule));
        }