コード例 #1
0
        public ActionResult RegisterPatient()
        {
            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            AssistantsBookAppointmentViewModel registerModel = (AssistantsBookAppointmentViewModel)TempData["RegisterModel"];

            return(View(registerModel));
        }
コード例 #2
0
        public ActionResult BookAppointment(AssistantsBookAppointmentViewModel model, string returnUrl)
        {
            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            if (model.SelectedTimeSlot > 0 && !string.IsNullOrEmpty(model.PatientPhoneNumber) && !string.IsNullOrEmpty(model.Details))
            {
                Appointment appointment = model.ToAppointment(model);
                appointment.AppointmentTimeId = (byte)model.SelectedTimeSlot;
                var patientData = new PatientData();
                int patientId   = patientData.GetPatientIdIfExists(model.PatientPhoneNumber); //returns 0 if patient doesn't exist

                if ((int)Session["roleID"] == (int)Roles.Assistant)
                {
                    if (patientId == 0) //returns 0 if patient doesn't exist
                    {
                        TempData["RegisterModel"] = model;
                        return(RedirectToAction("RegisterPatient", "Assistant"));
                    }
                    else
                    {
                        appointment.PatientId           = patientId;
                        appointment.AppointmentStatusId = (byte)ClinicManagementSystemDOL.Enums.AppointmentStatus.Open;
                        appointment.CreatedAt           = DateTime.Now;
                        try
                        {
                            if (new Appointments().AddAppointment(appointment))
                            {
                                return(RedirectToAction("AppointmentList", "Assistant"));
                            }
                            else
                            {
                                return(View(model));
                            }
                        }
                        catch (Exception ex)
                        {
                            ModelState.AddModelError("", ex.Message);
                            return(View(model));
                        }
                    }
                }
            }
            return(View(model));
        }
コード例 #3
0
        public ActionResult RegisterPatient(AssistantsBookAppointmentViewModel model, string returnUrl)
        {
            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            Users    user    = new Users();
            Patients patient = new Patients();

            AutoMapper.Mapper.Map(model, user);
            AutoMapper.Mapper.Map(model, patient);
            user.RoleId    = (int)Roles.Patient;
            user.CreatedBy = (int)Session["userId"];
            try
            {
                if (new Accounts().AddUser(user, patient))
                {
                    TempData["AppointmentData"] = model;
                    return(RedirectToAction("BookAppointment", "Assistant", new { id = 0, date = model.Date }));
                }
                else
                {
                    return(RedirectToAction("~/Assistant/Patients/Add"));
                }
            }
            catch (EmailAlreadyExistsEx ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
            catch (PhoneAlreadyExistsEx ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
        }
コード例 #4
0
        public ActionResult BookAppointment(int id, DateTime date)
        {
            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            TempData["SelectedDateForAppointment"] = date;
            var bookAppointmentDetails = new AssistantsBookAppointmentViewModel();

            bookAppointmentDetails.Date = date;
            if (id == 0)
            {
                bookAppointmentDetails = (AssistantsBookAppointmentViewModel)TempData["AppointmentData"];
            }
            else
            {
                bookAppointmentDetails.DoctorId = id;
                TempData["DoctorId"]            = id;
            }
            return(View(bookAppointmentDetails));
        }