Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<ItemGroup>
<PackageReference Include="MediatR" Version="12.5.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.DynamicLinq" Version="9.6.5" />
<PackageReference Include="Shared" Version="2025.6.1" />
<PackageReference Include="TransactionProcessor.Database" Version="2025.5.1" />
<PackageReference Include="Shared" Version="2025.7.9" />
<PackageReference Include="TransactionProcessor.Database" Version="2025.7.2-build188" />
</ItemGroup>

<ItemGroup>
Expand Down
62 changes: 31 additions & 31 deletions EstateReportingAPI.BusinessLogic/ReportingManager.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions EstateReportingAPI.Client/EstateReportingAPI.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClientProxyBase" Version="2025.6.1" />
<PackageReference Include="ClientProxyBase" Version="2025.7.9" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Shared.Results" Version="2025.6.1" />
<PackageReference Include="Shared.Results" Version="2025.7.9" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions EstateReportingAPI.IntegrationTests/ControllerTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@
this.Client = this.factory.CreateClient();
this.ApiClient = new EstateReportingApiClient((s) => "http://localhost", this.Client);

this.context = new EstateManagementSqlServerContext(GetLocalConnectionString($"EstateReportingReadModel{this.TestId.ToString()}"));
this.context = new EstateManagementContext(GetLocalConnectionString($"EstateReportingReadModel{this.TestId.ToString()}"));

this.helper = new DatabaseHelper(context);
await this.helper.CreateStoredProcedures(CancellationToken.None);
await this.SetupStandingData();
}

public virtual async Task DisposeAsync()

Check warning on line 52 in EstateReportingAPI.IntegrationTests/ControllerTestsBase.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
}

protected EstateManagementGenericContext context;
protected EstateManagementContext context;

protected abstract Task ClearStandingData();
protected abstract Task SetupStandingData();
Expand All @@ -65,7 +65,7 @@

protected Guid TestId;

internal async Task<Result<T?>> CreateAndSendHttpRequestMessage<T>(String url, CancellationToken cancellationToken)

Check warning on line 68 in EstateReportingAPI.IntegrationTests/ControllerTestsBase.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
requestMessage.Headers.Add("estateId", this.TestId.ToString());
Expand All @@ -79,7 +79,7 @@
return null;
}

internal async Task<Result<T?>> CreateAndSendHttpRequestMessage<T>(String url, String payload, CancellationToken cancellationToken)

Check warning on line 82 in EstateReportingAPI.IntegrationTests/ControllerTestsBase.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
requestMessage.Headers.Add("estateId", this.TestId.ToString());
Expand Down Expand Up @@ -126,7 +126,7 @@

public void Dispose()
{
EstateManagementGenericContext context = new EstateManagementSqlServerContext(ControllerTestsBase.GetLocalConnectionString($"EstateReportingReadModel{this.TestId.ToString()}"));
EstateManagementContext context = new EstateManagementContext(ControllerTestsBase.GetLocalConnectionString($"EstateReportingReadModel{this.TestId.ToString()}"));

Console.WriteLine($"About to delete database EstateReportingReadModel{this.TestId.ToString()}");
Boolean result = context.Database.EnsureDeleted();
Expand All @@ -153,6 +153,6 @@


public class TestDockerHelper : DockerHelper{
public override async Task CreateSubscriptions(){

Check warning on line 156 in EstateReportingAPI.IntegrationTests/ControllerTestsBase.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
// Nothing here
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
{
builder.ConfigureServices(containerBuilder =>
{
var context = new EstateManagementSqlServerContext(DatabaseConnectionString);
Func<string, EstateManagementGenericContext> f = connectionString => context;
var context = new EstateManagementContext(DatabaseConnectionString);
Func<string, EstateManagementContext> f = connectionString => context;

IDbContextFactory<EstateManagementGenericContext> factory = new DbContextFactory<EstateManagementGenericContext>(new TestConnectionStringConfigurationRepository(DatabaseConnectionString), f);
IDbContextFactory<EstateManagementContext> factory = new DbContextFactory<EstateManagementContext>(new TestConnectionStringConfigurationRepository(DatabaseConnectionString), f);

Check warning on line 44 in EstateReportingAPI.IntegrationTests/CustomWebApplicationFactory.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

'DbContextFactory<EstateManagementContext>' is obsolete: 'Replaced by DbContextResolver'

Check warning on line 44 in EstateReportingAPI.IntegrationTests/CustomWebApplicationFactory.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

'IDbContextFactory<EstateManagementContext>' is obsolete: 'Replaced by DbContextResolver'

IReportingManager manager = new ReportingManager(factory);

Expand Down Expand Up @@ -75,7 +75,7 @@
throw new NotImplementedException();
}

public async Task<string> GetConnectionString(string externalIdentifier, string connectionStringIdentifier,

Check warning on line 78 in EstateReportingAPI.IntegrationTests/CustomWebApplicationFactory.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
CancellationToken cancellationToken)
{
return DbConnectionString;
Expand Down Expand Up @@ -104,7 +104,7 @@
IOptionsMonitor<TestAuthHandlerOptions> options,
ILoggerFactory logger,
UrlEncoder encoder,
ISystemClock clock) : base(options, logger, encoder, clock)

Check warning on line 107 in EstateReportingAPI.IntegrationTests/CustomWebApplicationFactory.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

'AuthenticationHandler<TestAuthHandlerOptions>.AuthenticationHandler(IOptionsMonitor<TestAuthHandlerOptions>, ILoggerFactory, UrlEncoder, ISystemClock)' is obsolete: 'ISystemClock is obsolete, use TimeProvider on AuthenticationSchemeOptions instead.'

Check warning on line 107 in EstateReportingAPI.IntegrationTests/CustomWebApplicationFactory.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

'ISystemClock' is obsolete: 'Use TimeProvider instead.'
{
_defaultUserId = options.CurrentValue.DefaultUserId;
}
Expand Down
4 changes: 2 additions & 2 deletions EstateReportingAPI.IntegrationTests/DatabaseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ namespace EstateReportingAPI.IntegrationTests;
using Microsoft.EntityFrameworkCore;

public class DatabaseHelper{
private readonly EstateManagementGenericContext Context;
private readonly EstateManagementContext Context;

public DatabaseHelper(EstateManagementGenericContext context){
public DatabaseHelper(EstateManagementContext context){
this.Context = context;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@

}

public void Dispose()

Check warning on line 278 in EstateReportingAPI.IntegrationTests/DimensionControllerTests.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

'DimensionsControllerTests.Dispose()' hides inherited member 'ControllerTestsBase.Dispose()'. Use the new keyword if hiding was intended.
{
EstateManagementGenericContext context = new EstateManagementSqlServerContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));
EstateManagementContext context = new EstateManagementContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));

Console.WriteLine($"About to delete database EstateReportingReadModel{TestId.ToString()}");
bool result = context.Database.EnsureDeleted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="TransactionProcessor.Database" Version="2025.5.1" />
<PackageReference Include="TransactionProcessor.Database" Version="2025.7.2-build188" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
Expand All @@ -21,8 +21,9 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="Shared" Version="2025.6.1" />
<PackageReference Include="Shared.IntegrationTesting" Version="2025.6.1" />
<PackageReference Include="Shared" Version="2025.7.9" />
<PackageReference Include="Shared.Logger" Version="2025.7.9" />
<PackageReference Include="Shared.IntegrationTesting" Version="2025.7.9" />
<PackageReference Include="Ductus.FluentDocker" Version="2.10.59" />
<PackageReference Include="NLog" Version="5.5.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.5.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public async Task FactSettlementsController_TodaysSettlement_OperatorFilter_Sett

[Fact]
public async Task FactSettlementsController_LastSettlement_SettlementReturned() {
EstateManagementGenericContext context = new EstateManagementSqlServerContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));
EstateManagementContext context = new EstateManagementContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));

DatabaseHelper helper = new DatabaseHelper(context);

Expand Down Expand Up @@ -341,7 +341,7 @@ public async Task FactSettlementsController_LastSettlement_SettlementReturned()

[Fact]
public async Task FactSettlementsController_LastSettlement_NoSettlementRecords_SettlementReturned() {
EstateManagementGenericContext context = new EstateManagementSqlServerContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));
EstateManagementContext context = new EstateManagementContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));

DatabaseHelper helper = new DatabaseHelper(context);

Expand All @@ -355,7 +355,7 @@ public async Task FactSettlementsController_LastSettlement_NoSettlementRecords_S
[Fact]
public async Task FactSettlementsController_UnsettledFees_ByOperator_SettlementReturned() {
// Add some fees over a date range for multiple operators
EstateManagementGenericContext context = new EstateManagementSqlServerContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));
EstateManagementContext context = new EstateManagementContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));

DatabaseHelper helper = new DatabaseHelper(context);

Expand Down Expand Up @@ -407,7 +407,7 @@ public async Task FactSettlementsController_UnsettledFees_ByOperator_SettlementR
[Fact]
public async Task FactSettlementsController_UnsettledFees_ByOperator_OperatorFilter_SettlementReturned() {
// Add some fees over a date range for multiple operators
EstateManagementGenericContext context = new EstateManagementSqlServerContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));
EstateManagementContext context = new EstateManagementContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));

DatabaseHelper helper = new DatabaseHelper(context);

Expand Down Expand Up @@ -458,7 +458,7 @@ public async Task FactSettlementsController_UnsettledFees_ByOperator_OperatorFil
[Fact]
public async Task FactSettlementsController_UnsettledFees_ByMerchant_SettlementReturned() {
// Add some fees over a date range for multiple operators
EstateManagementGenericContext context = new EstateManagementSqlServerContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));
EstateManagementContext context = new EstateManagementContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));

DatabaseHelper helper = new DatabaseHelper(context);

Expand Down Expand Up @@ -504,7 +504,7 @@ public async Task FactSettlementsController_UnsettledFees_ByMerchant_SettlementR
[Fact]
public async Task FactSettlementsController_UnsettledFees_ByMerchant_MerchantFilter_SettlementReturned() {
// Add some fees over a date range for multiple operators
EstateManagementGenericContext context = new EstateManagementSqlServerContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));
EstateManagementContext context = new EstateManagementContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));

DatabaseHelper helper = new DatabaseHelper(context);

Expand Down Expand Up @@ -549,7 +549,7 @@ public async Task FactSettlementsController_UnsettledFees_ByMerchant_MerchantFil
[Fact]
public async Task FactSettlementsController_UnsettledFees_ByProduct_SettlementReturned() {
// Add some fees over a date range for multiple operators
EstateManagementGenericContext context = new EstateManagementSqlServerContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));
EstateManagementContext context = new EstateManagementContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));

DatabaseHelper helper = new DatabaseHelper(context);

Expand Down Expand Up @@ -609,7 +609,7 @@ public async Task FactSettlementsController_UnsettledFees_ByProduct_SettlementRe
[Fact]
public async Task FactSettlementsController_UnsettledFees_ByProduct_ProductFilter_SettlementReturned() {
// Add some fees over a date range for multiple operators
EstateManagementGenericContext context = new EstateManagementSqlServerContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));
EstateManagementContext context = new EstateManagementContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));

DatabaseHelper helper = new DatabaseHelper(context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ public async Task FactTransactionsControllerController_TodaysSalesValueByHour_Sa

[Fact]
public async Task FactTransactionsControllerController_TodaysFailedSales_SalesReturned() {
EstateManagementGenericContext context = new EstateManagementSqlServerContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));
EstateManagementContext context = new EstateManagementContext(GetLocalConnectionString($"EstateReportingReadModel{TestId.ToString()}"));
var todaysTransactions = new List<Transaction>();
var comparisonDateTransactions = new List<Transaction>();
DatabaseHelper helper = new DatabaseHelper(context);
Expand Down
3 changes: 2 additions & 1 deletion EstateReportingAPI.Tests/EstateReportingAPI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.5" />
Expand All @@ -19,6 +19,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="TransactionProcessor.Database" Version="2025.7.2-build188" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
Expand Down
20 changes: 5 additions & 15 deletions EstateReportingAPI/Bootstrapper/RepositoryRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,10 @@ public RepositoryRegistry(){
this.AddSingleton<IReportingManager, ReportingManager>();
}

this.AddSingleton<IDbContextFactory<EstateManagementGenericContext>, DbContextFactory<EstateManagementGenericContext>>();

this.AddSingleton<Func<String, EstateManagementGenericContext>>(cont => connectionString =>
{
String databaseEngine =
ConfigurationReader.GetValue("AppSettings", "DatabaseEngine");

return databaseEngine switch
{
"MySql" => new EstateManagementMySqlContext(connectionString),
"SqlServer" => new EstateManagementSqlServerContext(connectionString),
_ => throw new
NotSupportedException($"Unsupported Database Engine {databaseEngine}")
};
});
this.AddSingleton<IDbContextFactory<EstateManagementContext>, DbContextFactory<EstateManagementContext>>();

this.AddSingleton<Func<String, EstateManagementContext>>(cont => connectionString => {
return new EstateManagementContext(connectionString);
});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Data.SqlClient;
using MySqlConnector;
using Shared.General;
using Shared.Repositories;
using System.Data.Common;
Expand Down Expand Up @@ -39,23 +38,11 @@ public async Task<String> GetConnectionString(String externalIdentifier,
databaseName = $"{connectionStringIdentifier}{externalIdentifier}";
connectionString = ConfigurationReader.GetConnectionString(connectionStringIdentifier);

DbConnectionStringBuilder builder = null;

if (databaseEngine == "MySql")
{
builder = new MySqlConnectionStringBuilder(connectionString)
{
Database = databaseName
};
}
else
DbConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectionString)
{
// Default to SQL Server
builder = new SqlConnectionStringBuilder(connectionString)
{
InitialCatalog = databaseName
};
}
InitialCatalog = databaseName
};


return builder.ToString();
}
Expand Down
8 changes: 4 additions & 4 deletions EstateReportingAPI/EstateReportingAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@

<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.5" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.2" />
<PackageReference Include="Shared.Results" Version="2025.6.1" />
<PackageReference Include="Shared.Results.Web" Version="2025.6.1" />
<PackageReference Include="Shared.Results" Version="2025.7.9" />
<PackageReference Include="Shared.Results.Web" Version="2025.7.9" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Lamar" Version="15.0.0" />
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="15.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.5.0" />
<PackageReference Include="Shared" Version="2025.6.1" />
<PackageReference Include="Shared" Version="2025.7.9" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="9.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="9.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
Expand All @@ -36,7 +36,7 @@
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="8.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="8.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.5" />
<PackageReference Include="TransactionProcessor.Database" Version="2025.5.1" />
<PackageReference Include="TransactionProcessor.Database" Version="2025.7.2-build188" />
</ItemGroup>

<ItemGroup>
Expand Down
21 changes: 20 additions & 1 deletion EstateReportingAPI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using System.Diagnostics.CodeAnalysis;
using Lamar.Microsoft.DependencyInjection;
using NLog;
using System.Diagnostics.CodeAnalysis;
using NLog.Extensions.Logging;
using Shared.Logger;
using Shared.Middleware;

namespace EstateReportingAPI;

Expand All @@ -23,12 +27,27 @@ public static IHostBuilder CreateHostBuilder(string[] args)
.AddJsonFile("hosting.development.json", optional: true)
.AddEnvironmentVariables().Build();

String contentRoot = Directory.GetCurrentDirectory();
String nlogConfigPath = Path.Combine(contentRoot, "nlog.config");

LogManager.Setup(b =>
{
b.SetupLogFactory(setup =>
{
setup.AddCallSiteHiddenAssembly(typeof(NlogLogger).Assembly);
setup.AddCallSiteHiddenAssembly(typeof(Shared.Logger.Logger).Assembly);
setup.AddCallSiteHiddenAssembly(typeof(TenantMiddleware).Assembly);
});
b.LoadConfigurationFromFile(nlogConfigPath);
});

IHostBuilder hostBuilder = Host.CreateDefaultBuilder(args);
hostBuilder.UseWindowsService();
hostBuilder.UseLamar();
hostBuilder.ConfigureLogging(logging =>
{
logging.AddConsole();
logging.AddNLog();
});
hostBuilder.ConfigureWebHostDefaults(webBuilder =>
{
Expand Down
Loading
Loading