private FieldVisitInfo MergeOrCreateVisit(LocationInfo location, StageDischargeReadingRecord visitRecord) { var existingVisit = FindExistingVisit(visitRecord); if (existingVisit != null) { MergeWithExistingVisit(existingVisit, visitRecord); return(existingVisit); } var visitStart = visitRecord.MeasurementStartDateTime; var visitEnd = visitRecord.MeasurementEndDateTime; var fieldVisitDetails = new FieldVisitDetails(new DateTimeInterval(visitStart, visitEnd)) { Comments = visitRecord.Comments, Party = visitRecord.Party }; var fieldVisitInfo = _fieldDataResultsAppender.AddFieldVisit(location, fieldVisitDetails); CreatedVisits.Add(fieldVisitInfo); if (IsValidMeasurementId(visitRecord.MeasurementId)) { AddVisitByMeasurementId(fieldVisitInfo, visitRecord); } return(fieldVisitInfo); }