public void SaveImage(Folder parent, HttpPostedFileBase file)
 {
     var buffer = new byte[file.InputStream.Length];
     file.InputStream.Read(buffer, 0, (int) file.InputStream.Length);
     var image = new Image
                 {
                     Name = Path.GetFileName(file.FileName),
                     Folder = parent,
                     Image1 = buffer
                 };
     Db.Images.Add(image);
     Db.SaveChanges();
 }
        public void CreateDirectory(Folder parent, string name)
        {
            var path = VirtualPathUtility.AppendTrailingSlash(Path.Combine(parent.Path, parent.Name));

            Db.Folders.Add(new Folder {Name = name, ParentId = parent.Id, Path = path});
            Db.SaveChanges();
        }
 public IEnumerable<FileBrowserEntry> Folders(Folder parent)
 {
     return parent == null ? new FileBrowserEntry[] { } : parent.ChildFolders.Select(f => new FileBrowserEntry { Name = f.Name, EntryType = FileBrowserEntryType.Directory });
 }
 public IEnumerable<FileBrowserEntry> Images(Folder parent)
 {
     return parent == null ? new FileBrowserEntry[0] : parent.Images.Select(f => new FileBrowserEntry { Name = f.Name, EntryType = FileBrowserEntryType.File });
 }
 public void Delete(Folder folder)
 {
     Db.Folders.Remove(folder);
     Db.SaveChanges();
 }