public IActionResult Code(CodeToFindViewModel codeToFind) { var codeFounder = _codeFinderFactory.Create(codeToFind); var machingFiles = codeFounder.GetMachingFiles(); if(! machingFiles.Any()) { return View(new MachingFilesViewModel { CodeToFind=codeToFind, NumberOfMatchingFiles = 0, NotFound = true }); } var nextFile = 0; var bestMatchShortestFileContent = _codeProcessor.Process(machingFiles[nextFile++]); var matchingFiles = new MachingFilesViewModel { CodeToFind = codeToFind, FirstFileContent = bestMatchShortestFileContent, NextFile = nextFile, NumberOfMatchingFiles =machingFiles.Length, MachingFiles = machingFiles, }; return View(matchingFiles); }
public IActionResult Code(CodeToFindViewModel codeToFind) { var codeFounder = _codeFinderFactory.Create(codeToFind); var machingFiles = codeFounder.GetMachingFiles(); if (!machingFiles.Any()) { return(View(new MachingFilesViewModel { CodeToFind = codeToFind, NumberOfMatchingFiles = 0, NotFound = true })); } var nextFile = 0; var bestMatchShortestFileContent = _codeProcessor.Process(machingFiles[nextFile++]); var matchingFiles = new MachingFilesViewModel { CodeToFind = codeToFind, FirstFileContent = bestMatchShortestFileContent, NextFile = nextFile, NumberOfMatchingFiles = machingFiles.Length, MachingFiles = machingFiles, }; return(View(matchingFiles)); }