public bool DeleteDriveById(int driveId) { using (var context = new CustomZfileDbContext()) { context.Remove(new Drive { id = driveId }); context.SaveChanges(); } LocalFileManager.DelDir(BasePath + "/" + driveId.ToString()); return(true); }
public bool EditDrive(DriveConfig driveConfig) { using (var context = new CustomZfileDbContext()) { Drive d = context.drive.Find(driveConfig.id); if (d == null) { return(false); } d.name = driveConfig.name; context.drive.Update(d); context.SaveChanges(); } return(true); }
public int SaveNewDrive(string driveName, int userId) { Drive newDrive = new Drive { name = driveName, creator_id = userId }; int id; using (var context = new CustomZfileDbContext()) { var result = context.drive.Add(newDrive); context.SaveChanges(); id = result.Entity.id; } LocalFileManager.CreateDir(BasePath + "/" + id.ToString()); return(id); }
public bool UpdatePassword(string username, string password, string newPassword) { User u = UserExist(username, password); if (u == null) { return(false); } u.password = newPassword; using (var context = new CustomZfileDbContext()) { context.user.Update(u); context.SaveChanges(); } return(true); }