public async Task CreateResponse(IEnumerable <Enrollment> enrollments, string outputDirectory, CancellationToken cancellationToken) { foreach (var enrollment in enrollments) { var ouptutFilePath = _fileService.GetOuputFilePath(outputDirectory, enrollment.InsuranceCompany); var companyEnrollments = _enrollmentService.SortEnrollmentsForCompany(enrollments, enrollment.InsuranceCompany); var outputEnrollments = _jsonService.SerializeEnrollmentsToJson(companyEnrollments.ToList()); await _fileService.WriteOutputFile(outputEnrollments, ouptutFilePath, cancellationToken); } }