public bool RemoveProject(int projectId) { //throw new NotImplementedException(); Project project = GetProject(projectId); if (project != null) { bool error = false; try { var option = new TransactionOptions(); option.IsolationLevel = IsolationLevel.ReadCommitted; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option)) { project = GetProject(projectId); List<bool> success = new List<bool>(); foreach (User user in project.ProjectAdministrators) { success.Add(RemovePersonFromProject(project, user)); } foreach (User user in project.ProjectMembers) { success.Add(RemovePersonFromProject(project, user)); } foreach (File file in dbFile.GetAllFilesForProject(project.Id)) { success.Add(dbFile.RemoveFile(file)); } //bool f = dbFile.RemoveAllFilesFromProject(projectId); dbContext.Projects.DeleteOnSubmit(project); if (success.TrueForAll(x => x.Equals(true))) //Checks if all values in the List matches true, and returns true if so. { dbContext.SubmitChanges(); scope.Complete(); } else { scope.Dispose(); error = true; } } } catch (Exception e) { Console.WriteLine("Project could not be removed. Project id: " + projectId + "Error: \n" + e); return false; } if (error != true) { return true; } else { return false; } } return false; }