diff --git a/Hcs.WebApp/Components/Layout/MainLayout.razor b/Hcs.WebApp/Components/Layout/MainLayout.razor index a871193..b16a828 100644 --- a/Hcs.WebApp/Components/Layout/MainLayout.razor +++ b/Hcs.WebApp/Components/Layout/MainLayout.razor @@ -34,6 +34,7 @@ + diff --git a/Hcs.WebApp/Components/Pages/Objects/MeteringDevices.razor b/Hcs.WebApp/Components/Pages/Objects/MeteringDevices.razor new file mode 100644 index 0000000..9c97d27 --- /dev/null +++ b/Hcs.WebApp/Components/Pages/Objects/MeteringDevices.razor @@ -0,0 +1,59 @@ +@page "/objects/metering-devices" + +@using Hcs.WebApp.Services +@using Microsoft.AspNetCore.Authorization +@using System.Security.Claims + +@inherits DataPageBase + +@attribute [Authorize] + +@inject MeteringDeviceService MeteringDeviceService + +Приборы учета + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +@code { + protected override Campaign.CampaignType? SyncCampaignType => Campaign.CampaignType.ExportSupplyContracts_15_7_0_1; + + protected override Campaign.CampaignType? ParseCampaignType => null; + + protected override bool HasPermission(ClaimsPrincipal user) + { + return user.IsOperatorOrHigher(); + } + + protected override Task> GetDataAsync() + { + return MeteringDeviceService.GetAllMeteringDevicesAsync(); + } +} diff --git a/Hcs.WebApp/Program.cs b/Hcs.WebApp/Program.cs index 0d78aab..be0d537 100644 --- a/Hcs.WebApp/Program.cs +++ b/Hcs.WebApp/Program.cs @@ -74,6 +74,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/Hcs.WebApp/Services/AccountService.cs b/Hcs.WebApp/Services/AccountService.cs index 843c543..95e9dfe 100644 --- a/Hcs.WebApp/Services/AccountService.cs +++ b/Hcs.WebApp/Services/AccountService.cs @@ -18,11 +18,11 @@ namespace Hcs.WebApp.Services { PropertiesToExcludeOnUpdate = [ - nameof(SupplyContract.ThirdPartyId) + nameof(Account.ThirdPartyId) ], UpdateByProperties = [ - nameof(SupplyContract.HcsId) + nameof(Account.HcsId) ] }); } diff --git a/Hcs.WebApp/Services/MeteringDeviceService.cs b/Hcs.WebApp/Services/MeteringDeviceService.cs new file mode 100644 index 0000000..6d9c6e6 --- /dev/null +++ b/Hcs.WebApp/Services/MeteringDeviceService.cs @@ -0,0 +1,30 @@ +using EFCore.BulkExtensions; +using Hcs.WebApp.Data.Hcs; +using Microsoft.EntityFrameworkCore; + +namespace Hcs.WebApp.Services +{ + public class MeteringDeviceService(IDbContextFactory factory) : HcsServiceBase(factory) + { + public async Task> GetAllMeteringDevicesAsync() + { + using var context = GetNewContext(); + return await context.MeteringDevices.ToListAsync(); + } + + public async Task UpsertMeteringDevices(HcsDbContext context, IEnumerable meteringDevices) + { + await context.BulkInsertOrUpdateAsync(meteringDevices, new BulkConfig() + { + PropertiesToExcludeOnUpdate = + [ + nameof(MeteringDevice.ThirdPartyId) + ], + UpdateByProperties = + [ + nameof(MeteringDevice.HcsId) + ] + }); + } + } +}