示例#1
0
        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));
        }
示例#2
0
 internal void AlignValues(ReportEntry newEntry)
 {
     BeginTime       = newEntry.BeginTime;
     EndTime         = newEntry.EndTime;
     WorkDescription = newEntry.WorkDescription;
 }