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

36 lines
894 B
C#
Raw Normal View History

2023-02-24 11:58:47 +00:00
using Innovenergy.Backend.Model;
using Innovenergy.Backend.Utils;
2023-02-16 12:57:06 +00:00
using SQLite;
2023-02-24 11:58:47 +00:00
namespace Innovenergy.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);
}
}