private IList <KMDAbsenceReport> Build(VacationReport report, KMDAbsenceOperation kmdAbsenceOperation) { var list = new List <KMDAbsenceReport>(); var baseAbsence = BuildBase(report, kmdAbsenceOperation); var sameDay = baseAbsence.StartDate.Date == baseAbsence.EndDate.Date; if (sameDay || (report.StartTime == null && report.EndTime == null)) { // Single report; baseAbsence.StartTime = report.StartTime; baseAbsence.EndTime = report.EndTime; list.Add(baseAbsence); return(list); } if (report.StartTime != null) { list.Add(BuildStart(report, kmdAbsenceOperation)); } list.Add(BuildCenter(report, kmdAbsenceOperation)); if (report.EndTime != null) { list.Add(BuildEnd(report, kmdAbsenceOperation)); } return(list); }
private KMDAbsenceReport BuildEnd(VacationReport report, KMDAbsenceOperation kmdAbsenceOperation) { var absence = BuildBase(report, kmdAbsenceOperation); absence.StartDate = absence.EndDate; absence.EndDate = absence.EndDate; absence.StartTime = null; absence.EndTime = report.EndTime; return(absence); }
private KMDAbsenceReport BuildCenter(VacationReport report, KMDAbsenceOperation kmdAbsenceOperation) { var absence = BuildBase(report, kmdAbsenceOperation); if (report.StartTime != null) { absence.StartDate = absence.StartDate.AddDays(1); } if (report.EndTime != null) { absence.EndDate = absence.EndDate.AddDays(-1); } return(absence); }
public static string AsString(this KMDAbsenceOperation kmdAbsenceOperation) { switch (kmdAbsenceOperation) { case KMDAbsenceOperation.Create: return("INS"); case KMDAbsenceOperation.Edit: return("MOD"); case KMDAbsenceOperation.Delete: return("DEL"); default: throw new ArgumentOutOfRangeException(nameof(kmdAbsenceOperation), kmdAbsenceOperation, null); } }
private KMDAbsenceReport BuildBase(VacationReport report, KMDAbsenceOperation kmdAbsenceOperation) { var startDate = report.StartTimestamp.ToDateTime(); var endDate = report.EndTimestamp.ToDateTime(); string extraData = ""; if (report.VacationType == VacationType.Care) { extraData = report.AdditionalData.PadLeft(2, '0'); } return(new KMDAbsenceReport { EmploymentId = report.Employment.EmploymentId, KmdAbsenceOperation = kmdAbsenceOperation, Type = report.VacationType, StartDate = startDate, EndDate = endDate, ExtraData = extraData }); }