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)); }
public ICodeFinder Create(CodeToFindViewModel model) { var keywords = model.Keywords.Split(','); var searchedPath = model.SearchedPath; var fileExtensionPattern = model.FileExtensionPattern; return new CodeFinder( keywords, searchedPath, fileExtensionPattern); }
public ICodeFinder Create(CodeToFindViewModel model) { var keywords = model.Keywords.Split(','); var searchedPath = model.SearchedPath; var fileExtensionPattern = model.FileExtensionPattern; return(new CodeFinder(keywords, searchedPath, fileExtensionPattern)); }
public IActionResult MatchingFiles( [FromForm] CodeToFindViewModel codeToFind) { if (!ModelState.IsValid) { return(View(codeToFind)); } return(RedirectToAction("Code", codeToFind)); }