// GET public ActionResult FilteredPhysicians(int?patientID, int?physicianID, string expertise, int?page) { if (patientID != null) { ViewBag.PatientID = patientID.Value; } int pageNumber = (page ?? 1); var viewModel = new SelectPhysicianData(); viewModel.Physicians = db.Physicians.Where(p => p.AppUser.Active) .Include(p => p.Appointment) .OrderBy(p => p.AppUser.FullName) .ToPagedList(pageNumber, pageSize); if (physicianID != null) { viewModel.Physicians = viewModel.Physicians .Where(p => p.PhysicianID == physicianID) .OrderBy(p => p.AppUser.FullName) .ToPagedList(pageNumber, pageSize); } if (!String.IsNullOrEmpty(expertise)) { viewModel.Physicians = viewModel.Physicians .Where(p => p.Expertise.ToLower() == expertise.ToLower()) .OrderBy(p => p.AppUser.FullName) .ToPagedList(pageNumber, pageSize); } //viewModel.Physicians = viewModel.Physicians.ToList(); return(PartialView(viewModel)); }
// GET: Physicians public ActionResult CreateAppointment(int?patientID, int?physicianID, int?page) { ViewBag.PhysicianList = db.Physicians.Where(p => p.AppUser.Active).Include(a => a.AppUser).OrderBy(p => p.AppUser.FullName).ToList(); int pageNumber = (page ?? 1); var viewModel = new SelectPhysicianData(); viewModel.Patient = db.Patients.Find(patientID); viewModel.Physicians = db.Physicians.Where(p => p.AppUser.Active) .Include(p => p.Appointment) .OrderBy(p => p.AppUser.FullName) .ToPagedList(pageNumber, pageSize); //viewModel.Physicians = viewModel.Physicians.OrderBy(p => p.AppUser.FullName).ToPagedList(pageNumber, pageSize); viewModel.Appointment = new Appointment(); viewModel.Appointment.PatientID = patientID.Value; ViewBag.PatientID = patientID.Value; if (physicianID != null) { ViewBag.PhysicianID = physicianID.Value; viewModel.Appointment.PhysicianID = physicianID.Value; var dayBegin = DateTime.Now.Date; var dayEnd = dayBegin.AddDays(1); var appointments = db.Appointments.Where(a => a.PhysicianID == physicianID && a.PlannedStartDate > dayBegin && a.PlannedStartDate < dayEnd && a.StatusID != Constants.SS_AP_CANCELED); var fullSchedule = ConfigurationManager.AppSettings["FullSchedule"].Split(','); var existingTimes = new string[] { }.ToList(); foreach (Appointment ap in appointments) { existingTimes.Add(ap.PlannedStartDate.Hour.ToString().PadLeft(2, '0') + ":" + ap.PlannedStartDate.Minute.ToString().PadLeft(2, '0') ); } var availableTimesForDay = fullSchedule.Except(existingTimes).ToList(); ViewBag.AvailableToday = availableTimesForDay; } return(View(viewModel)); }