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

38 lines
909 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);
2023-03-09 15:32:11 +00:00
public Int64 CreateInstallation(Installation installation)
2023-02-16 12:57:06 +00:00
{
return Create(installation);
}
2023-03-09 15:32:11 +00:00
public Boolean UpdateInstallation(Installation installation)
2023-02-16 12:57:06 +00:00
{
2023-02-16 14:08:50 +00:00
return Update(installation);
2023-02-16 12:57:06 +00:00
}
2023-03-09 15:32:11 +00:00
public Boolean DeleteInstallation(Installation installation)
2023-02-16 12:57:06 +00:00
{
User2Installation.Delete(i => i.InstallationId == installation.Id);
2023-02-16 12:57:06 +00:00
return Delete(installation);
}
2023-03-09 15:33:14 +00:00
2023-02-16 12:57:06 +00:00
}