Threw out "deleted" Backups as we backup our db after each transaction.

This commit is contained in:
Kim 2023-09-08 10:27:09 +02:00
parent 7da9389358
commit 3484d4bca3
9 changed files with 0 additions and 108 deletions

View File

@ -1,11 +0,0 @@
using SQLite;
namespace InnovEnergy.App.Backend.DataTypes;
public class DeletedFolder : Folder
{
[PrimaryKey]
public override Int64 Id { get; set; }
}
//Deleted Things need to have AT LEAST every property that normal things have

View File

@ -1,10 +0,0 @@
using SQLite;
namespace InnovEnergy.App.Backend.DataTypes;
//Deleted Things need to have AT LEAST every property that normal things have
public class DeletedInstallation : Installation
{
[PrimaryKey]
public override Int64 Id { get; set; }
}

View File

@ -1,13 +0,0 @@
using SQLite;
namespace InnovEnergy.App.Backend.DataTypes;
//Deleted Things need to have AT LEAST every property that normal things have
public class DeletedUser : User
{
public override String Name { get; set; } = null!;
[PrimaryKey]
public override Int64 Id { get; set; }
}

View File

@ -23,17 +23,6 @@ public static class FolderMethods
.NotNull(); .NotNull();
} }
public static DeletedFolder ToDeletedFolder(this Folder folder)
{
var deletedFolder = new DeletedFolder();
foreach (var property in folder.GetType().GetProperties())
{
property.SetValue(deletedFolder,property.GetValue(folder));
}
return deletedFolder;
}
public static IEnumerable<User> UsersWithInheritedAccess(this Folder folder) public static IEnumerable<User> UsersWithInheritedAccess(this Folder folder)
{ {
return folder return folder

View File

@ -70,17 +70,6 @@ public static class InstallationMethods
.SelectMany(f => f.UsersWithDirectAccess()) .SelectMany(f => f.UsersWithDirectAccess())
.NotNull(); .NotNull();
} }
public static DeletedInstallation ToDeletedInstallation(this Installation installation)
{
var deletedInstallation = new DeletedInstallation();
foreach (var property in installation.GetType().GetProperties())
{
property.SetValue(deletedInstallation, property.GetValue(installation));
}
return deletedInstallation;
}
public static IEnumerable<Folder> Ancestors(this Installation installation) public static IEnumerable<Folder> Ancestors(this Installation installation)
{ {

View File

@ -74,7 +74,6 @@ public static class SessionMethods
&& folder is not null && folder is not null
&& user.HasWriteAccess && user.HasWriteAccess
&& user.HasAccessTo(folder) && user.HasAccessTo(folder)
&& Db.Create(folder.ToDeletedFolder())
&& Db.Delete(folder); && Db.Delete(folder);
} }
@ -144,7 +143,6 @@ public static class SessionMethods
&& installation is not null && installation is not null
&& user.HasWriteAccess && user.HasWriteAccess
&& user.HasAccessTo(installation) && user.HasAccessTo(installation)
&& Db.Create(installation.ToDeletedInstallation())
&& Db.Delete(installation); && Db.Delete(installation);
} }
@ -205,7 +203,6 @@ public static class SessionMethods
&& userToDelete is not null && userToDelete is not null
&& sessionUser.HasWriteAccess && sessionUser.HasWriteAccess
&& sessionUser.HasAccessTo(userToDelete) && sessionUser.HasAccessTo(userToDelete)
&& Db.Create(sessionUser.ToDeletedUser())
&& Db.Delete(userToDelete); && Db.Delete(userToDelete);
} }

View File

@ -204,17 +204,6 @@ public static class UserMethods
user.Password = other.Password; user.Password = other.Password;
return user; return user;
} }
public static DeletedUser ToDeletedUser(this User user)
{
var deletedUser = new DeletedUser();
foreach (var property in user.GetType().GetProperties())
{
property.SetValue(deletedUser,property.GetValue(user));
}
return deletedUser;
}
public static User HidePassword(this User user) public static User HidePassword(this User user)
{ {

View File

@ -20,30 +20,15 @@ public static partial class Db
return Insert(installation); return Insert(installation);
} }
public static Boolean Create(DeletedInstallation installation)
{
return Insert(installation);
}
public static Boolean Create(Folder folder) public static Boolean Create(Folder folder)
{ {
return Insert(folder); return Insert(folder);
} }
public static Boolean Create(DeletedFolder folder)
{
return Insert(folder);
}
public static Boolean Create(User user) public static Boolean Create(User user)
{ {
return Insert(user); return Insert(user);
} }
public static Boolean Create(DeletedUser user)
{
return Insert(user);
}
public static Boolean Create(Session session) public static Boolean Create(Session session)
{ {

View File

@ -33,10 +33,7 @@ public static partial class Db
// fileConnection.Backup(memoryConnection.DatabasePath); // fileConnection.Backup(memoryConnection.DatabasePath);
memoryConnection.CreateTable<User>(); memoryConnection.CreateTable<User>();
memoryConnection.CreateTable<DeletedUser>();
memoryConnection.CreateTable<Installation>(); memoryConnection.CreateTable<Installation>();
memoryConnection.CreateTable<DeletedInstallation>();
memoryConnection.CreateTable<DeletedFolder>();
memoryConnection.CreateTable<Folder>(); memoryConnection.CreateTable<Folder>();
memoryConnection.CreateTable<FolderAccess>(); memoryConnection.CreateTable<FolderAccess>();
memoryConnection.CreateTable<InstallationAccess>(); memoryConnection.CreateTable<InstallationAccess>();
@ -71,19 +68,6 @@ public static partial class Db
{ {
memoryConnection.Insert(obj); memoryConnection.Insert(obj);
} }
foreach (var obj in fileConnection.Table<DeletedInstallation>())
{
memoryConnection.Insert(obj);
}
foreach (var obj in fileConnection.Table<DeletedUser>())
{
memoryConnection.Insert(obj);
}
foreach (var obj in fileConnection.Table<DeletedFolder>())
{
memoryConnection.Insert(obj);
}
return memoryConnection; return memoryConnection;
}))(); }))();
@ -100,10 +84,6 @@ public static partial class Db
public static TableQuery<FolderAccess> FolderAccess => Connection.Table<FolderAccess>(); public static TableQuery<FolderAccess> FolderAccess => Connection.Table<FolderAccess>();
public static TableQuery<InstallationAccess> InstallationAccess => Connection.Table<InstallationAccess>(); public static TableQuery<InstallationAccess> InstallationAccess => Connection.Table<InstallationAccess>();
public static TableQuery<OrderNumber2Installation> OrderNumber2Installation => Connection.Table<OrderNumber2Installation>(); public static TableQuery<OrderNumber2Installation> OrderNumber2Installation => Connection.Table<OrderNumber2Installation>();
public static TableQuery<DeletedInstallation> DeletedInstallations => Connection.Table<DeletedInstallation>();
public static TableQuery<DeletedUser> DeletedUsers => Connection.Table<DeletedUser>();
public static TableQuery<DeletedFolder> DeletedFolders => Connection.Table<DeletedFolder>();
public static void Init() public static void Init()
{ {
@ -118,10 +98,7 @@ public static partial class Db
Connection.RunInTransaction(() => Connection.RunInTransaction(() =>
{ {
Connection.CreateTable<User>(); Connection.CreateTable<User>();
Connection.CreateTable<DeletedUser>();
Connection.CreateTable<Installation>(); Connection.CreateTable<Installation>();
Connection.CreateTable<DeletedInstallation>();
Connection.CreateTable<DeletedFolder>();
Connection.CreateTable<Folder>(); Connection.CreateTable<Folder>();
Connection.CreateTable<FolderAccess>(); Connection.CreateTable<FolderAccess>();
Connection.CreateTable<InstallationAccess>(); Connection.CreateTable<InstallationAccess>();