public AppointmentController() { appointment = new Appointment(); appointmentListViewModel = new AppointmentListViewModel(); appointmentBusinessLayer = new AppointmentBusinessLayer(); patientBusinessLayer = new PatientBusinessLayer(); doctorBusinessLayer = new DoctorBusinessLayer(); }
public void TestValidateAppointment() { AppointmentViewModel appointment = new AppointmentViewModel(); appointment.DoctorId = 1; appointment.AppointmentDate = DateTime.Today; appointment.TimeSlot = TimeSlots.Timings[1]; AppointmentBusinessLayer businessLayer = new AppointmentBusinessLayer(); Assert.IsNull(businessLayer.ValidateAppointment(appointment)); }
public ActionResult Dashboard(DashboardModel dashboard) { List <int> stats = userBusinessLayer.GetDashboardStats(Session["Role"].ToString(), int.Parse(Session["UserId"].ToString())); appointmentBusinessLayer = new AppointmentBusinessLayer(); dashboard.totalUsers = stats[0]; dashboard.totalDoctors = stats[1]; dashboard.totalAppointments = stats[2]; dashboard.totalAppointmentsToday = stats[3]; dashboard.totalPatients = stats[4]; appointmentBusinessLayer.CancelPastAppointments(); return(View(dashboard)); }
public ActionResult Create(MedicalHistory medicalHistory) { if (ModelState.IsValid) { MedicalHistoriesBusinessLayer businessLayer = new MedicalHistoriesBusinessLayer(); if (appointmentId != null) { medicalHistory.AppointmentId = (int)appointmentId; AppointmentBusinessLayer appointmentBusinessLayer = new AppointmentBusinessLayer(); appointmentBusinessLayer.ChangeAppointmentStatus(medicalHistory.AppointmentId); } medicalHistory.PatientId = patientId; businessLayer.AddHistory(medicalHistory); Logging.loggInfo($"Medcial history added of the patient having patient id = {medicalHistory.PatientId}"); return Redirect("/Patients/Details/" + patientId); } return View(medicalHistory); }
public ActionResult Index(AppointmentViewModel appointmentViewModel) { try { appointmentBusinessLayer = new AppointmentBusinessLayer(); Dictionary <string, string> errorMsg = appointmentBusinessLayer.ValidateAppointment(appointmentViewModel); if (errorMsg != null) { ModelState.AddModelError(errorMsg.ElementAt(0).Key, errorMsg.ElementAt(0).Value); return(View("Index")); } appointmentViewModel.PatientId = patientId; Dictionary <string, string> errMsg = appointmentBusinessLayer.FixAppointment(appointmentViewModel); if (errMsg != null) { ModelState.AddModelError(errMsg.ElementAt(0).Key, errMsg.ElementAt(0).Value); } else { Logging.loggInfo($"Appointment is added for patient id {appointmentViewModel.PatientId} with Doctor ID {appointmentViewModel.DoctorId } on date {appointmentViewModel.AppointmentDate } at time {appointmentViewModel.TimeSlot }"); if ((int)Session["Role"] == 3) { return(Redirect("/Patients/Details/" + patientId)); } else { return(Redirect("/Appointment/AppointmentList")); } } return(new HttpNotFoundResult()); } catch (Exception) { return(RedirectToAction("Error", "Error")); } }