public BrowseViewModel(Library currentLibrary, string relativePath, IEnumerable<FileResult> results) { CurrentLibrary = currentLibrary; RelativePath = relativePath; Results = results; PathCrumbs = GetAllSubPathsContainedWithinRelativePath(relativePath); }
public bool TryGetLibrary(int? libraryId, out Library library) { if (!libraryId.HasValue) { library = null; return false; } library = FetchLibraries().First(x => x.LibraryId == libraryId); return (library != null); }
public IEnumerable<FileResult> FetchResultsForPath(Library library, string relativePath) { string fullPath = string.Format("{0}{1}", library.FullPathName, relativePath); if (!library.IsDescendant(fullPath)) throw new HttpException(403,"No no no!"); var folders = FileSystemEnumerator.GetDirectories(fullPath, "*.*"); foreach (string r in folders) { yield return new FileResult(library.MakePathRelativeToLibrary(r), true); } var files = FileSystemEnumerator.GetFiles(fullPath, "*.*"); foreach (string r in files) { yield return new FileResult(library.MakePathRelativeToLibrary(r), false); } }