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

36 lines
906 B
C#
Raw Normal View History

2023-03-08 12:20:33 +00:00
using InnovEnergy.App.Backend.Model;
using InnovEnergy.App.Backend.Utils;
2023-02-16 12:57:06 +00:00
using SQLite;
2023-03-08 12:20:33 +00:00
namespace InnovEnergy.App.Backend.Database;
2023-02-16 12:57:06 +00:00
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-16 12:57:06 +00:00
public Result DeleteInstallation(Installation installation)
{
User2Installation.Delete(i => i.InstallationId == installation.Id);
2023-02-16 12:57:06 +00:00
return Delete(installation);
}
}