private static ImportResult InitResult(IEnumerable<File> files)
 {
     ImportResult newResult = new ImportResult()
     {
         TotalLines = files.Count(),
     };
     return newResult;
 }
 private void AddFilesToResult(IEnumerable<File> files, ImportResult newResult, IEnumerable<string> existentEmails, ref int duplicated, ref int added)
 {
     _importResultRepository.Insert(newResult);
     _importResultRepository.Save();
     var newFiles = new List<File>();
     foreach (var file in files)
     {
         if (existentEmails.Any(e => e == file.Email))
         {
             duplicated++;
         }
         else
         {
             added++;
             //this sucked ad performances when inserting the parent objects:/
             //newResult.ImportedFiles.Add(file);
             file.ImportResultId = newResult.Id;
             newFiles.Add(file);
         }
     }
     _fileRepository.BulkInsert(newFiles);
     existentEmails = null;
 }
 private static void UpdateResult(ImportResult newResult, int duplicated, int added)
 {
     newResult.TotalLinesImported = added;
     newResult.TotalLinesNotImported = duplicated;
     newResult.ExecutionTime = 0;
 }
 private void SaveResult(ImportResult newResult, Stopwatch timer)
 {
     timer.Stop();
     newResult.ExecutionTime = timer.ElapsedMilliseconds/1000d;
     _importResultRepository.Update(newResult);
     _importResultRepository.Save();
 }