public async Task <(int numberOfFailedReadings, int numberOfSuccessfulReadings)> ProcessReadings(string csvFile) { (var successFulReadings, var failedLines) = _meterCsvReader.ParseCsv(csvFile); // Check to see if there is anything to process once we parsed the file if (successFulReadings.Count == 0) { return(successFulReadings.Count, failedLines.Count); } int numberOfSuccessfulReadings = successFulReadings.Count; int numberOfFailedReadings = failedLines.Count; // Write the failed CSV lines off to the DB foreach (string failedLine in failedLines) { await _repo.AddFailedLine(failedLine); } foreach (var meterReading in successFulReadings) { var persistedMeterReading = await _repo.AddReading(meterReading); if (persistedMeterReading == null) { numberOfSuccessfulReadings--; numberOfFailedReadings++; } } return(numberOfSuccessfulReadings, numberOfFailedReadings); }