public UpdateReportEntryResult UpsertReportEntry(ReportEntry entry) { var overlapping = _reportEntries.Where(f => f.HasTimesSet) .Any( f => f.Id != entry.Id && (entry.BeginTime.ToTimeSpan() < f.EndTime.Reduce(() => null).ToTimeSpan()) && (entry.EndTime.Reduce(() => null).ToTimeSpan() > f.BeginTime.ToTimeSpan())); if (overlapping) { return(new UpdateReportEntryResult(false, "Report contains overlapping entries.")); } var existingEntry = _reportEntries.SingleOrDefault(e => e == entry); if (existingEntry != null) { existingEntry.AlignValues(entry); } else { _reportEntries.Add(entry); } return(new UpdateReportEntryResult(true, string.Empty)); }
internal void AlignValues(ReportEntry newEntry) { BeginTime = newEntry.BeginTime; EndTime = newEntry.EndTime; WorkDescription = newEntry.WorkDescription; }