using System; using BS.Shared.DataContracts; namespace BeWoPlanerMobil.Util { public class JsonAbsenceTime { public string StartDate { get; set; } = string.Empty; public string EndDate { get; set; } = string.Empty; public string AbsenceInterval { get; set; } = string.Empty; public string AbsenceReason { get; set; } public string Notice { get; set; } = string.Empty; public JsonAbsenceTime(DateTime? startDate, DateTime? endDate, string notice, AbsenceReasonDC absenceReason) { if (startDate.HasValue && !endDate.HasValue) { AbsenceInterval = $"Ab dem {startDate.Value:dd.MM.yyyy}"; } else if(startDate.HasValue) { StartDate = startDate.Value.ToString("dd.MM.yyyy"); EndDate = endDate.Value.ToString("dd.MM.yyyy"); AbsenceInterval = $"{StartDate} - {EndDate}"; } if (!string.IsNullOrWhiteSpace(notice)) { Notice = notice; } if (absenceReason?.Description != null) { AbsenceReason = absenceReason.Description; } } } }