/// <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(); } }
/// <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); }