Exemplo n.º 1
0
        /// <summary>
        /// Gets the appointment end date.
        /// </summary>
        /// <param name="dateStart">The appointment start date.</param>
        /// <param name="dateFormat">The date format to be used.</param>
        /// <returns>Returns the end date as DateTime.</returns>
        private DateTime GetAppointmentDateEnd(DateTime dateStart, string dateFormat)
        {
            DateTime?dateEnd;

            do
            {
                Console.Write($"Geben Sie das Enddatum im Format \"{dateFormat}\" ein um fortzufahren: ");
                dateEnd = AppointmentViewGeneral.GetUserInputDateTime(dateFormat);

                if (dateEnd == null)
                {
                    AppointmentViewGeneral.PrintInvalidInput();
                }
                else
                {
                    DateTime dateMaxLength = dateStart.AddYears(1);

                    if (dateEnd > dateMaxLength)
                    {
                        Console.WriteLine("\nDer Termin darf nicht länger als ein Jahr andauern.");
                        dateEnd = null;
                    }
                    else if (dateEnd < dateStart)
                    {
                        Console.WriteLine("\nDas Enddatum darf nicht in der Vergangenheit liegen.");
                        dateEnd = null;
                    }
                }
            }while (dateEnd == null);

            return(dateEnd.Value);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the appointment title.
        /// </summary>
        /// <returns>Returns the title as string.</returns>
        private string GetAppointmentTitle()
        {
            Console.Write("\nWie lautet der Titel des Termins: ");
            string title = AppointmentViewGeneral.GetUserInputString();

            return(title);
        }
        /// <summary>
        /// Deletes all appointments of the specified date.
        /// </summary>
        /// <param name="date">The specified date.</param>
        private void RemoveAppointmentByDate(DateTime date)
        {
            bool hasAppointments = appointmentManager.HasAppointmentsOnSpecifiedDate(date);

            if (hasAppointments)
            {
                Console.WriteLine($"\nEs wurden ein oder mehrere Termine gefunden.");
                Console.Write($"Geben Sie \"{CONFIRMATION_STRING}\" ein um die Löschung zu bestätigen: ");
                string input = AppointmentViewGeneral.GetUserInputString();

                if (input == CONFIRMATION_STRING)
                {
                    appointmentManager.DeleteAppointmentsOfSpecifiedDate(date);
                    Console.WriteLine("\nDie Termine wurden gelöscht.");
                }
                else
                {
                    Console.WriteLine("\nDer Löschvorgang wurde abgebrochen.");
                }
            }
            else
            {
                Console.WriteLine("\nEs wurden keine Termine gefunden.");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets how often the appointment should be created.
        /// </summary>
        /// <returns>The number of appointments as number.</returns>
        private int GetNumberOfRecurrences()
        {
            int input;

            do
            {
                Console.WriteLine("\nWie oft soll der Termin erstellt werden?");
                Console.Write("Geben Sie die entsprechende Nummer ein um fortzufahren: ");
                input = AppointmentViewGeneral.GetUserInputInt();
            }while (input <= 0);

            return(input);
        }
        /// <summary>
        /// Deletes the appointment(s) by date.
        /// </summary>
        internal void DeleteAppointmentByDate()
        {
            Console.Write($"\nGeben Sie das Startdatum im Format \"dd.MM.yyyy\" ein um fortzufahren: ");
            DateTime?date = AppointmentViewGeneral.GetUserInputDateTime("dd.MM.yyyy");

            if (date != null)
            {
                RemoveAppointmentByDate(date.Value);
            }
            else
            {
                AppointmentViewGeneral.PrintInvalidInput();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the appointment start date.
        /// </summary>
        /// <param name="dateFormat">The date format to be used.</param>
        /// <returns>Returns the start date as DateTime.</returns>
        private DateTime GetAppointmentDateStart(string dateFormat)
        {
            DateTime?date;

            do
            {
                Console.Write($"\nGeben Sie das Startdatum im Format \"{dateFormat}\" ein um fortzufahren: ");
                date = AppointmentViewGeneral.GetUserInputDateTime(dateFormat);

                if (date == null)
                {
                    AppointmentViewGeneral.PrintInvalidInput();
                }
            }while (date == null);

            return(date.Value);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the recurrence type to be created.
        /// </summary>
        /// <returns>Returns the recurrence type as an enum.</returns>
        private RecurrenceType GetRecurrenceType()
        {
            RecurrenceType recurrenceType;

            do
            {
                Console.WriteLine("\n1. Einmaliger Termin");
                Console.WriteLine("2. Wöchtenlicher Termin");
                Console.WriteLine("3. Jährlicher Termin");
                Console.WriteLine("0. Abbruch");
                Console.Write("Geben Sie die entsprechende Nummer ein um fortzufahren: ");
                int input = AppointmentViewGeneral.GetUserInputInt();

                switch (input)
                {
                case 1:
                    recurrenceType = RecurrenceType.Never;
                    break;

                case 2:
                    recurrenceType = RecurrenceType.Weekly;
                    break;

                case 3:
                    recurrenceType = RecurrenceType.Yearly;
                    break;

                case 0:
                    recurrenceType = RecurrenceType.None;
                    AppointmentViewGeneral.PrintCanceledAction();
                    break;

                default:
                    recurrenceType = RecurrenceType.Invalid;
                    AppointmentViewGeneral.PrintInvalidInput();
                    break;
                }
            }while (recurrenceType == RecurrenceType.Invalid);

            return(recurrenceType);
        }
        /// <summary>
        /// Deletes the specified appointment.
        /// </summary>
        /// <param name="index">The specified index in the appointment list.</param>
        private void RemoveAppointmentByIndex(int index)
        {
            var appointments = appointmentManager.GetAppointmentsOfSameId(index);

            if (appointments.Count > 1)
            {
                Console.WriteLine($"\nEs wurden zukünftige Termine für diesen Termin gefunden. Möchten Sie diese auch löschen?");
                Console.Write($"Geben Sie \"{CONFIRMATION_STRING}\" ein um alle zukünftige Termine zu löschen: ");
                string input = AppointmentViewGeneral.GetUserInputString();

                if (input == CONFIRMATION_STRING)
                {
                    appointmentManager.DeleteSpecifiedAndFutureAppointments(index);
                    Console.WriteLine($"\nDer Termin und alle zukünftigen Termine wurden gelöscht.");
                }
                else
                {
                    appointmentManager.DeleteAppointment(index);
                    Console.WriteLine($"/nDer angegebene Termin wurde gelöscht.");
                }
            }
            else
            {
                Console.WriteLine($"\nSoll der Termin wirklich gelöscht werden?");
                Console.Write($"Geben Sie \"{CONFIRMATION_STRING}\" ein um die Löschung zu bestätigen: ");
                string input = AppointmentViewGeneral.GetUserInputString();

                if (input == CONFIRMATION_STRING)
                {
                    appointmentManager.DeleteAppointment(index);
                    Console.WriteLine("\nDer angegebene Termin wurde gelöscht.");
                }
                else
                {
                    Console.WriteLine("\nDer Löschvorgang wurde abgebrochen.");
                }
            }
        }
        /// <summary>
        /// Deletes all appointments.
        /// </summary>
        internal void DeleteAllAppointments()
        {
            if (appointmentManager.Appointments.Any())
            {
                Console.WriteLine($"\nMöchten Sie wirklich alle Termine löschen?");
                Console.Write($"Geben Sie \"{CONFIRMATION_STRING}\" ein um die Löschung zu bestätigen: ");
                string input = AppointmentViewGeneral.GetUserInputString();

                if (input == CONFIRMATION_STRING)
                {
                    appointmentManager.DeleteAllAppointments();
                    Console.WriteLine("\nEs wurden alle Termine gelöscht.");
                }
                else
                {
                    Console.WriteLine("\nDer Löschvorgang wurde abgebrochen.");
                }
            }
            else
            {
                Console.WriteLine("\nEs wurden keine Termine gefunden.");
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets the appointment type to be created.
        /// </summary>
        /// <returns>Returns the appointment type as an enum.</returns>
        private AppointmentType GetAppointmentType()
        {
            AppointmentType appointmentType;

            do
            {
                Console.WriteLine("\n1. Ganztägiger Termin");
                Console.WriteLine("2. Termin mit Dauer");
                Console.WriteLine("0. Abbruch");
                Console.Write("Geben Sie die entsprechende Nummer ein um fortzufahren: ");
                int input = AppointmentViewGeneral.GetUserInputInt();

                switch (input)
                {
                case 1:
                    appointmentType = AppointmentType.AllDay;
                    break;

                case 2:
                    appointmentType = AppointmentType.Duration;
                    break;

                case 0:
                    appointmentType = AppointmentType.None;
                    AppointmentViewGeneral.PrintCanceledAction();
                    break;

                default:
                    appointmentType = AppointmentType.Invalid;
                    AppointmentViewGeneral.PrintInvalidInput();
                    break;
                }
            }while (appointmentType == AppointmentType.Invalid);

            return(appointmentType);
        }
        /// <summary>
        /// Deletes the appointments by index.
        /// </summary>
        internal void DeleteAppointmentByIndex()
        {
            if (appointmentManager.Appointments.Any())
            {
                appointmentViewDisplay.ShowAllAppointments();

                Console.Write($"\nGeben Sie die Terminnummer ein um fortzufahren: ");
                int index = AppointmentViewGeneral.GetUserInputInt();

                int appointmentsCount = appointmentManager.Appointments.Count;
                if (index > 0 && index <= appointmentsCount)
                {
                    RemoveAppointmentByIndex(--index);
                }
                else
                {
                    Console.WriteLine("Die eingegebene Terminnummer existiert nicht.");
                }
            }
            else
            {
                Console.WriteLine("\nEs wurden keine Termine gefunden.");
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// The main menu of the software.
        /// </summary>
        private void MainMenu()
        {
            bool isRunning = true;

            while (isRunning)
            {
                Console.WriteLine("\n##################################################\n");
                Console.WriteLine("1. Termin erstellen");
                Console.WriteLine("2. Übersicht der Termine des aktuellen Tages");
                Console.WriteLine("3. Übersicht der Termine der nächsten sieben Tage");
                Console.WriteLine("4. Übersicht aller Termine");
                Console.WriteLine("5. Termin löschen");
                Console.WriteLine("6. Alle Termine eines Tages löschen");
                Console.WriteLine("7. Alle Termine löschen");
                Console.WriteLine("8. Termine speichern");
                Console.WriteLine("0. Programm beenden");
                Console.Write("Geben Sie die entsprechende Nummer ein um fortzufahren: ");
                int input = AppointmentViewGeneral.GetUserInputInt();

                switch (input)
                {
                case 1:
                    appointmentViewCreate.CreateNewAppointment();
                    break;

                case 2:
                    appointmentViewDisplay.ShowAppointmentsOfToday();
                    break;

                case 3:
                    appointmentViewDisplay.ShowAppointmentsOfNextSevenDays();
                    break;

                case 4:
                    appointmentViewDisplay.ShowAllAppointments();
                    break;

                case 5:
                    appointmentViewDelete.DeleteAppointmentByIndex();
                    break;

                case 6:
                    appointmentViewDelete.DeleteAppointmentByDate();
                    break;

                case 7:
                    appointmentViewDelete.DeleteAllAppointments();
                    break;

                case 8:
                    appointmentViewStorage.SaveAppointments();
                    break;

                case 0:
                    isRunning = false;
                    break;

                default:
                    AppointmentViewGeneral.PrintInvalidInput();
                    break;
                }
            }
        }