Пример #1
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.");
        }