add Create User2Installation and User2Folder to Db
This commit is contained in:
parent
f9cb419da0
commit
96018a5867
|
@ -4,7 +4,6 @@ using InnovEnergy.App.Backend.DataTypes.Methods;
|
||||||
using InnovEnergy.App.Backend.Relations;
|
using InnovEnergy.App.Backend.Relations;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using static System.Net.HttpStatusCode;
|
using static System.Net.HttpStatusCode;
|
||||||
using static System.String;
|
|
||||||
using Folder = InnovEnergy.App.Backend.DataTypes.Folder;
|
using Folder = InnovEnergy.App.Backend.DataTypes.Folder;
|
||||||
using Installation = InnovEnergy.App.Backend.DataTypes.Installation;
|
using Installation = InnovEnergy.App.Backend.DataTypes.Installation;
|
||||||
using Object = System.Object;
|
using Object = System.Object;
|
||||||
|
|
|
@ -29,10 +29,18 @@ public static partial class Db
|
||||||
return Connection.Insert(user) > 0;
|
return Connection.Insert(user) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Boolean Create(Session session)
|
public static Boolean Create(Session session)
|
||||||
{
|
{
|
||||||
return Connection.Insert(session) > 0;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using InnovEnergy.App.Backend.DataTypes;
|
using InnovEnergy.App.Backend.DataTypes;
|
||||||
using InnovEnergy.App.Backend.DataTypes.Methods;
|
|
||||||
using InnovEnergy.App.Backend.Relations;
|
using InnovEnergy.App.Backend.Relations;
|
||||||
using InnovEnergy.Lib.Utils;
|
using InnovEnergy.Lib.Utils;
|
||||||
using SQLite;
|
using SQLite;
|
||||||
|
@ -39,10 +38,6 @@ public static partial class Db
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var installation = Installations.First();
|
|
||||||
UserMethods.CreateAndSaveInstallationS3ApiKey(installation);
|
|
||||||
|
|
||||||
|
|
||||||
Observable.Interval(TimeSpan.FromDays(1))
|
Observable.Interval(TimeSpan.FromDays(1))
|
||||||
.StartWith(0) // Do it right away (on startup)
|
.StartWith(0) // Do it right away (on startup)
|
||||||
.Subscribe(Cleanup); // and then daily
|
.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 _)
|
private static void Cleanup(Int64 _)
|
||||||
|
|
Loading…
Reference in New Issue