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,
                         Data = buffer
                     };
     Db.Images.InsertOnSubmit(image);
     Db.SubmitChanges();
 }
 partial void DeleteFolder(Folder instance);
 partial void UpdateFolder(Folder instance);
 partial void InsertFolder(Folder instance);
		private void detach_ChildFolders(Folder entity)
		{
			this.SendPropertyChanging();
			entity.Parent = null;
		}
		private void attach_ChildFolders(Folder entity)
		{
			this.SendPropertyChanging();
			entity.Parent = this;
		}
        public void CreateDirectory(Folder parent, string name)
        {
            var path = VirtualPathUtility.AppendTrailingSlash(Path.Combine(parent.Path, parent.Name));

            Db.Folders.InsertOnSubmit(new Folder {Name = name, ParentId = parent.Id, Path = path});
            Db.SubmitChanges();
        }
 public IEnumerable<DirectoryEntry> Folders(Folder parent)
 {
     return parent == null ? new DirectoryEntry[] {} : parent.ChildFolders.Select(f => new DirectoryEntry {Name = f.Name});
 }
 public IEnumerable<FileEntry> Images(Folder parent)
 {
     return parent == null ? new FileEntry[0] : parent.Images.Select(f => new FileEntry {Name = f.Name});
 }
 public void Delete(Folder folder)
 {
     Db.Folders.DeleteOnSubmit(folder);
     Db.SubmitChanges();
 }