add Create User2Installation and User2Folder to Db

This commit is contained in:
ig 2023-03-16 09:15:59 +01:00
parent f9cb419da0
commit 96018a5867
3 changed files with 10 additions and 44 deletions

View File

@ -4,7 +4,6 @@ using InnovEnergy.App.Backend.DataTypes.Methods;
using InnovEnergy.App.Backend.Relations;
using Microsoft.AspNetCore.Mvc;
using static System.Net.HttpStatusCode;
using static System.String;
using Folder = InnovEnergy.App.Backend.DataTypes.Folder;
using Installation = InnovEnergy.App.Backend.DataTypes.Installation;
using Object = System.Object;

View File

@ -29,10 +29,18 @@ public static partial class Db
return Connection.Insert(user) > 0;
}
public static Boolean Create(Session session)
{
return Connection.Insert(session) > 0;
}
public static Boolean Create(User2Installation user2Installation)
{
return Connection.Insert(user2Installation) > 0;
}
public static Boolean Create(User2Folder user2Folder)
{
return Connection.Insert(user2Folder) > 0;
}
}

View File

@ -1,6 +1,5 @@
using System.Reactive.Linq;
using InnovEnergy.App.Backend.DataTypes;
using InnovEnergy.App.Backend.DataTypes.Methods;
using InnovEnergy.App.Backend.Relations;
using InnovEnergy.Lib.Utils;
using SQLite;
@ -39,10 +38,6 @@ public static partial class Db
});
var installation = Installations.First();
UserMethods.CreateAndSaveInstallationS3ApiKey(installation);
Observable.Interval(TimeSpan.FromDays(1))
.StartWith(0) // Do it right away (on startup)
.Subscribe(Cleanup); // and then daily
@ -72,43 +67,7 @@ public static partial class Db
public static Boolean AddToAccessibleInstallations(Int64 userId, Int64 updatedInstallationId)
{
var con = new User2Installation
{
UserId = userId,
InstallationId = updatedInstallationId
};
try
{
Connection.Insert(con);
return true;
}
catch (Exception e)
{
return false;
}
}
public static Boolean AddToAccessibleFolders(Int64 userId, Int64 updatedFolderId)
{
var con = new User2Folder
{
UserId = userId,
FolderId = updatedFolderId
};
try
{
Connection.Insert(con);
return true;
}
catch (Exception e)
{
return false;
}
}
private static void Cleanup(Int64 _)