2023-02-16 12:57:06 +00:00
|
|
|
using Backend.Model;
|
|
|
|
using Backend.Utils;
|
|
|
|
using SQLite;
|
|
|
|
|
|
|
|
namespace Backend.Database;
|
|
|
|
|
|
|
|
public partial class Db
|
|
|
|
{
|
|
|
|
|
|
|
|
private TableQuery<Installation> Installations => _Db.Table<Installation>();
|
|
|
|
|
|
|
|
public Int32 NbInstallations => Installations.Count();
|
|
|
|
|
|
|
|
public Installation? GetInstallationById(Int64 id) => Installations
|
|
|
|
.FirstOrDefault(u => u.Id == id);
|
|
|
|
|
|
|
|
public Result CreateInstallation(Installation installation)
|
|
|
|
{
|
|
|
|
return Create(installation);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Result UpdateInstallation(Installation installation)
|
|
|
|
{
|
2023-02-16 14:08:50 +00:00
|
|
|
return Update(installation);
|
2023-02-16 12:57:06 +00:00
|
|
|
}
|
|
|
|
|
2023-02-23 10:26:55 +00:00
|
|
|
|
2023-02-16 12:57:06 +00:00
|
|
|
public Result DeleteInstallation(Installation installation)
|
|
|
|
{
|
2023-02-23 10:26:55 +00:00
|
|
|
User2Installation.Delete(i => i.InstallationId == installation.Id);
|
2023-02-16 12:57:06 +00:00
|
|
|
|
|
|
|
return Delete(installation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|