Implement parsing

This commit is contained in:
2025-11-22 11:10:03 +09:00
parent 8095bf8ebc
commit dfb60cb9f0
8 changed files with 102 additions and 13 deletions

View File

@ -27,6 +27,12 @@ namespace Hcs.WebApp.Services
return fileToParse;
}
public async Task<FileToParse> GetFileToParseByOperationIdAsync(int operationId)
{
using var context = GetNewContext();
return await GetFileToParseByOperationIdAsync(context, operationId);
}
public async Task<FileToParse> GetFileToParseByOperationIdAsync(HcsDbContext context, int operationId)
{
return await context.FilesToParse.SingleAsync(x => x.LastParseOperationId == operationId);

View File

@ -1,4 +1,5 @@
using Hcs.WebApp.Data.Hcs;
using EFCore.BulkExtensions;
using Hcs.WebApp.Data.Hcs;
using Microsoft.EntityFrameworkCore;
namespace Hcs.WebApp.Services
@ -10,5 +11,21 @@ namespace Hcs.WebApp.Services
using var context = GetNewContext();
return await context.Houses.ToListAsync();
}
public async Task UpsertHouses(IEnumerable<House> houses)
{
using var context = GetNewContext();
await context.BulkInsertOrUpdateAsync(houses, new BulkConfig()
{
PropertiesToExcludeOnUpdate =
[
nameof(House.ThirdPartyId)
],
UpdateByProperties =
[
nameof(House.HcsId)
]
});
}
}
}