Пример #1
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                string strDateTimeSelected = string.Format("{0} {1}", collection["dateSelected"], collection["timeSelected"]);

                DateTime.TryParse(strDateTimeSelected, out DateTime dateTimeSelected);

                // TODO: Add insert logic here
                AppointmentModel appointment = new AppointmentModel
                {
                    PatientId           = Convert.ToInt16(collection["patient.Id"]),
                    SpecialtyId         = Convert.ToInt16(collection["specialtyId"]),
                    AppointmentDateTime = dateTimeSelected
                };

                string msg = _appointmentManager.CreateAppointment(appointment);

                if (!string.IsNullOrEmpty(msg))
                {
                    ViewBag.ErrorDateExist = msg;
                }

                return(RedirectToAction("Create", "Appointment", new { id = appointment.PatientId }));
            }
            catch
            {
                return(View());
            }
        }
Пример #2
0
        protected void ButtonAddAppointment_Click(object sender, EventArgs e)
        {
            List <Doctor> doctors = getDoctors();

            Doctor doctor = doctors[DropDownListPatients.SelectedIndex];

            DateTime date = getRequestedAppointmentTime();

            AppointmentInfo appointment = new AppointmentInfo(
                TextBoxDepartment.Text,
                getPatientID(),
                doctor.DoctorID,
                date,
                TextBoxPurpose.Text
                );

            if (!AppointmentManager.IsAppointmentAvailable(appointment))
            {
                LabelAddStatus.Text = "That appointment slot is not available, please select a different time/date.";
                return;
            }

            bool scheduleSuccess = AppointmentManager.CreateAppointment(appointment);

            if (scheduleSuccess)
            {
                LabelAddStatus.Text = "Your appointment has been created.";
            }
            else
            {
                LabelAddStatus.Text = "There was an error while scheduling your appointment, please try again later.";
            }
        }
Пример #3
0
        /// <summary>
        /// Creates one or multiple appointments.
        /// </summary>
        internal void CreateNewAppointment()
        {
            // Appointment Type
            AppointmentType appointmentType = GetAppointmentType();

            if (appointmentType == AppointmentType.None)
            {
                return;
            }

            // Date Format
            string dateFormat;

            if (appointmentType == AppointmentType.AllDay)
            {
                dateFormat = "dd.MM.yyyy";
            }
            else
            {
                dateFormat = "dd.MM.yyyy HH:mm";
            }

            // Recurrence Type
            RecurrenceType recurrenceType = GetRecurrenceType();

            if (recurrenceType == RecurrenceType.None)
            {
                return;
            }

            // Number Of Appointments
            int numberOfRecurrences = 1;

            if (recurrenceType == RecurrenceType.Weekly || recurrenceType == RecurrenceType.Yearly)
            {
                numberOfRecurrences = GetNumberOfRecurrences();
            }

            // Appointment Title
            string title = GetAppointmentTitle();

            // Appointment Start Date & End Date
            DateTime dateStart = GetAppointmentDateStart(dateFormat);
            DateTime dateEnd;

            if (appointmentType == AppointmentType.Duration)
            {
                dateEnd = GetAppointmentDateEnd(dateStart, dateFormat);
            }
            else
            {
                dateEnd = new DateTime(dateStart.Year, dateStart.Month, dateStart.Day, 23, 59, 59, 999);
            }

            // Create Appointment
            if (recurrenceType == RecurrenceType.Never)
            {
                appointmentManager.CreateAppointment(title, dateStart, dateEnd);
            }
            else
            {
                appointmentManager.CreateMultipleAppointments(title, dateStart, dateEnd, recurrenceType, numberOfRecurrences);
            }

            Console.WriteLine("\nDie Termin(e) wurden erfolgreich angelegt.");
        }