fixed deletion

This commit is contained in:
Kim 2023-09-08 09:45:56 +02:00
parent fd52a94d18
commit 50e01e6c8c
2 changed files with 20 additions and 14 deletions

View File

@ -24,36 +24,41 @@ public static partial class Db
FolderAccess .Delete(r => r.FolderId == f.Id);
Installations.Delete(r => r.ParentId == f.Id);
var delete = Folders.Delete(r => r.Id == f.Id);
var deleteSuccess = delete > 0;
if (deleteSuccess)
BackupDatabase();
return delete > 0;
return deleteSuccess;
}
}
public static Boolean Delete(Installation installation)
{
return RunTransaction(DeleteInstallationAndItsDependencies);
var deleteSuccess = RunTransaction(DeleteInstallationAndItsDependencies);
if (deleteSuccess)
BackupDatabase();
return deleteSuccess;
Boolean DeleteInstallationAndItsDependencies()
{
InstallationAccess.Delete(i => i.InstallationId == installation.Id);
var delete = Installations.Delete(i => i.Id == installation.Id);
BackupDatabase();
return delete > 0;
return Installations.Delete(i => i.Id == installation.Id) > 0;
}
}
public static Boolean Delete(User user)
{
return RunTransaction(DeleteUserAndHisDependencies);
var deleteSuccess = RunTransaction(DeleteUserAndHisDependencies);
if (deleteSuccess)
BackupDatabase();
return deleteSuccess;
Boolean DeleteUserAndHisDependencies()
{
FolderAccess .Delete(u => u.UserId == user.Id);
InstallationAccess.Delete(u => u.UserId == user.Id);
var delete = Users.Delete(u => u.Id == user.Id);
BackupDatabase();
return delete > 0;
return Users.Delete(u => u.Id == user.Id) > 0;
}
}
@ -64,6 +69,7 @@ public static partial class Db
private static Boolean Delete(Session session)
{
var delete = Sessions.Delete(s => s.Id == session.Id) > 0;
if (delete)
BackupDatabase();
return delete;
}