Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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"));
            }
        }