Add supply contracts page

This commit is contained in:
2025-11-23 18:08:51 +09:00
parent 5ec3776f6f
commit 1ba1576943
8 changed files with 122 additions and 4 deletions

View File

@ -0,0 +1,31 @@
using EFCore.BulkExtensions;
using Hcs.WebApp.Data.Hcs;
using Microsoft.EntityFrameworkCore;
namespace Hcs.WebApp.Services
{
public class SupplyContractService(IDbContextFactory<HcsDbContext> factory) : HcsServiceBase(factory)
{
public async Task<IEnumerable<SupplyContract>> GetAllSupplyContractsAsync()
{
using var context = GetNewContext();
return await context.SupplyContracts.ToListAsync();
}
public async Task UpsertSupplyContracts(IEnumerable<SupplyContract> supplyContracts)
{
using var context = GetNewContext();
await context.BulkInsertOrUpdateAsync(supplyContracts, new BulkConfig()
{
PropertiesToExcludeOnUpdate =
[
nameof(SupplyContract.ThirdPartyId)
],
UpdateByProperties =
[
nameof(SupplyContract.HcsId)
]
});
}
}
}