public async Task <(int, int, int)> InsertInstances(List <CourseInstance> courseInstances) { int newCourses = 0; int newCourseInstances = 0; foreach (CourseInstance c in courseInstances) { bool courseExists = false; bool courseInstanceExists = false; (c.Course, courseExists) = await _courseRepository.AddIfNotExists(c.Course); courseInstanceExists = (await _courseInstanceRepository.AddIfNotExists(c)).exists; if (!courseExists) { newCourses++; } if (!courseInstanceExists) { newCourseInstances++; } } return(newCourses, newCourseInstances, (courseInstances.Count - newCourseInstances)); }