/// <summary> /// Adds a folder to the database. /// </summary> /// <param name="name">The name of the folder</param> /// <param name="parentFolderId">The id of the parent folder. Null if it's a root folder.</param> public int AddFolder(String name, int parentFolderId) { using (PieFactoryEntities context = new PieFactoryEntities()) { Folder folder = new Folder(); folder.name = name; folder.parentFolderId = parentFolderId; context.Folders.AddObject(folder); context.SaveChanges(); return folder.id; } }
/// <summary> /// Adds a user to the database. /// </summary> /// <param name="email">The email of the user</param> /// <param name="password">The encrypted password of the user</param> /// <returns>The id of the added user. -1 if a user with the given email already exists</returns> public int AddUser(String email, String password) { using (PieFactoryEntities context = new PieFactoryEntities()) { User user = new User(); user.email = email; user.password = password; //Add a root folder named "root" Folder folder = new Folder(); folder.name = "root"; user.Folder = folder; context.Users.AddObject(user); context.SaveChanges(); return user.id; } }
/// <summary> /// Deprecated Method for adding a new object to the Folders EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToFolders(Folder folder) { base.AddObject("Folders", folder); }
/// <summary> /// Create a new Folder object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="name">Initial value of the name property.</param> public static Folder CreateFolder(global::System.Int32 id, global::System.String name) { Folder folder = new Folder(); folder.id = id; folder.name = name; return folder; }
public VirtualFileSystem() { _root = new Folder("root"); }