public void RegisterMeasurement(long missionId, Measurement measurement) { Mission mission = missions.GetById(missionId); var joint = joints.GetBySectionAndRail(mission.Span, mission.LeftRail) .Where(x => domainService.Close(x.Position, measurement.Position)) .FirstOrDefault(null); if (joint != null) { domainService.AddMeasurement(joint, measurement); joints.Save(); } else { throw new InvalidOperationException("Could not identify measured joint"); } }