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

@ -76,7 +76,7 @@ public static class InstallationMethods
var deletedInstallation = new DeletedInstallation(); var deletedInstallation = new DeletedInstallation();
foreach (var property in installation.GetType().GetProperties()) foreach (var property in installation.GetType().GetProperties())
{ {
property.SetValue(deletedInstallation ,property.GetValue(installation)); property.SetValue(deletedInstallation, property.GetValue(installation));
} }
return deletedInstallation; return deletedInstallation;

View File

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