Add metering devices page

This commit is contained in:
2025-11-28 16:45:20 +09:00
parent 8eb8786341
commit 59fcb7576a
5 changed files with 93 additions and 2 deletions

View File

@ -0,0 +1,30 @@
using EFCore.BulkExtensions;
using Hcs.WebApp.Data.Hcs;
using Microsoft.EntityFrameworkCore;
namespace Hcs.WebApp.Services
{
public class MeteringDeviceService(IDbContextFactory<HcsDbContext> factory) : HcsServiceBase(factory)
{
public async Task<IEnumerable<MeteringDevice>> GetAllMeteringDevicesAsync()
{
using var context = GetNewContext();
return await context.MeteringDevices.ToListAsync();
}
public async Task UpsertMeteringDevices(HcsDbContext context, IEnumerable<MeteringDevice> meteringDevices)
{
await context.BulkInsertOrUpdateAsync(meteringDevices, new BulkConfig()
{
PropertiesToExcludeOnUpdate =
[
nameof(MeteringDevice.ThirdPartyId)
],
UpdateByProperties =
[
nameof(MeteringDevice.HcsId)
]
});
}
}
}