Innovenergy_trunk/csharp/app/Backend/Database/Installation.cs

37 lines
896 B
C#
Raw Normal View History

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)
{
return Update(installation); // TODO
}
public Result DeleteInstallation(Installation installation)
{
User2Installation
.Where(i => i.InstallationId == installation.Id)
.Delete();
return Delete(installation);
}
}