fixup accounting api hard decepdnecy

This commit is contained in:
honzapatCZ 2026-09-16 16:39:59 +02:00
parent 6477b79086
commit f0662ee1d9
2 changed files with 6 additions and 7 deletions

View File

@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal;
using NejAccountingAPI.Models;
using NejCommon.Models;
namespace AutoMapProperty;
@ -8,13 +8,13 @@ public class AutoMapPropertyUtils
{
public static T Create<T>(IServiceProvider provider) where T : class
{
var appDb = provider.GetRequiredService<AppDbContext>();
var appDb = provider.GetRequiredService<CommonDbContext>();
return appDb.Create<T>();
}
public static T Create<T, TParent>(IServiceProvider provider, TParent parent, string name) where T : class, new() where TParent : class
{
var appDb = provider.GetRequiredService<AppDbContext>();
var appDb = provider.GetRequiredService<CommonDbContext>();
return appDb.Create<T, TParent>(parent, name);
}

View File

@ -2,7 +2,7 @@
using System.Text.RegularExpressions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using NejAccountingAPI.Models;
using NejCommon.Models;
namespace NejCommon.Utils;
@ -31,7 +31,7 @@ public class PostgresSqlHealthCheck : IHealthCheck
// Try to get DbContext via DI
using var scope = _serviceProvider.CreateScope();
var dbContext = scope.ServiceProvider
.GetRequiredService<AppDbContext>();
.GetRequiredService<CommonDbContext>();
// Execute simple query to check connectivity
var canConnect = await dbContext.Database
@ -64,8 +64,7 @@ public class PostgresSqlHealthCheck : IHealthCheck
}
// Test real query to validate permissions
var recordCount = await dbContext.ApiKeys
.CountAsync(cancellationToken);
//var recordCount = await dbContext.;
return HealthCheckResult.Healthy(
"PostgreSQL connection is healthy",