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);
        }
        /// <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.º 3
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.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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;
                }
            }
        }