public ActionResult RequestAppointment(AppointmentViewModel appointmentViewModel, FormCollection formCollection) { bool isError = false; var appointmentSlots = new string[11]; AppointementRepository appointmentRepository = new AppointementRepository(); if (formCollection["assignChkBx"] == null) { isError = true; ModelState.AddModelError("", "You need to select the time of appointment"); } else appointmentSlots = formCollection["assignChkBx"].Split(','); var appointmentModel = new AppointmentViewModel(); appointmentModel.Providers = new DrodownItemsViewModel(); appointmentModel.Providers.Items = GetProvidersForAppointment(); appointmentModel.AppointmentDate = appointmentViewModel.AppointmentDate; appointmentModel.ProviderId = appointmentViewModel.ProviderId; appointmentModel.ReasonForVisit = appointmentViewModel.ReasonForVisit; appointmentModel.AppointmentViewModelList = appointmentRepository.GetAppointmentsByPatientID(int.Parse(Session["PatientId"].ToString()), appointmentViewModel.AppointmentDate); if (isError == false) { try { var appointementList = new List<Appointment>(); foreach (string time in appointmentSlots) { appointementList.Add(new Appointment { AppointmentId= 0, AppointmentDate = DateTime.Parse(appointmentViewModel.AppointmentDate), ProviderId = appointmentViewModel.ProviderId, ReasonForVisit = appointmentViewModel.ReasonForVisit, Status = "Booked", Time = time, PatientId = int.Parse(Session["PatientId"].ToString()) }); } appointmentRepository.AddAppointments(appointementList); appointmentModel.AppointmentViewModelList = appointmentRepository.GetAppointmentsByPatientID(int.Parse(Session["PatientId"].ToString()), appointmentViewModel.AppointmentDate); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } return View(appointmentModel); }
public ActionResult CheckAvailability(int providerId, string date) { DateTime dateTime; if (date != "" && DateTime.TryParse(date, out dateTime)) { if (dateTime.Date >= DateTime.Now.Date) { var availableSlots = new AppointementRepository().GetAvailableAppointmentBookings(providerId, date); return PartialView("AppointmentAvailaibilitySlotsWebGrid", availableSlots); } } return PartialView("AppointmentAvailaibilitySlotsWebGrid", new List<string>()); }
public ActionResult GetPatientAppointments(int patientId, string appointmentDate) { var appointmentRepository = new AppointementRepository(); var appointmentViewModelList = new List<AppointmentViewModelEntity>(); var appointments = appointmentRepository.GetAppointmentsByPatientID(patientId, appointmentDate); foreach (var appointment in appointments) { appointmentViewModelList.Add(new AppointmentViewModelEntity { PatientId = appointment.PatientId, AppointmentId = appointment.AppointmentId, AppointmentDate = appointment.AppointmentDate, ProviderId = appointment.ProviderId, ReasonForVisit = appointment.ReasonForVisit, Status = appointment.Status, Time = appointment.Time }); } return PartialView("PatientAppointmentGrid", appointmentViewModelList); }
private List<Appointment> GetAppointmentsForPatient(int patientId) { var appointmentRepository = new AppointementRepository(); return appointmentRepository.GetAppointmentsByPatientID(patientId, DateTime.Now.Date.ToString()); }