diff --git a/src/ElectionResults.API/Dockerfile b/src/ElectionResults.API/Dockerfile
index e16db29..5cfd91b 100644
--- a/src/ElectionResults.API/Dockerfile
+++ b/src/ElectionResults.API/Dockerfile
@@ -1,20 +1,25 @@
-#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
+#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
-FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
+FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
+USER app
WORKDIR /app
-EXPOSE 80
-EXPOSE 443
+EXPOSE 8080
+EXPOSE 8081
-FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
+FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
+ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["ElectionResults.API/ElectionResults.API.csproj", "ElectionResults.API/"]
-RUN dotnet restore "ElectionResults.API/ElectionResults.API.csproj"
+COPY ["ElectionResults.Core/ElectionResults.Core.csproj", "ElectionResults.Core/"]
+COPY ["ElectionResults.Importer/ElectionResults.Importer.csproj", "ElectionResults.Importer/"]
+RUN dotnet restore "./ElectionResults.API/ElectionResults.API.csproj"
COPY . .
WORKDIR "/src/ElectionResults.API"
-RUN dotnet build "ElectionResults.API.csproj" -c Release -o /app/build
+RUN dotnet build "./ElectionResults.API.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
-RUN dotnet publish "ElectionResults.API.csproj" -c Release -o /app/publish
+ARG BUILD_CONFIGURATION=Release
+RUN dotnet publish "./ElectionResults.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
diff --git a/src/ElectionResults.API/ElectionResults.API.csproj b/src/ElectionResults.API/ElectionResults.API.csproj
index 3a5890d..f4efc64 100644
--- a/src/ElectionResults.API/ElectionResults.API.csproj
+++ b/src/ElectionResults.API/ElectionResults.API.csproj
@@ -1,31 +1,29 @@
-
- netcoreapp3.1
+ net8.0
0a7d747b-d86b-44b1-8e0f-69bc4c568730
Linux
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
+
+
@@ -38,4 +36,4 @@
-
+
\ No newline at end of file
diff --git a/src/ElectionResults.API/Import/TurnoutCrawler.cs b/src/ElectionResults.API/Import/TurnoutCrawler.cs
index 6574287..a0cfa26 100644
--- a/src/ElectionResults.API/Import/TurnoutCrawler.cs
+++ b/src/ElectionResults.API/Import/TurnoutCrawler.cs
@@ -67,10 +67,8 @@ private async Task ProcessStream(Stream csvStream)
var csvContent = await ReadCsvContent(csvStream);
TextReader sr = new StringReader(csvContent);
var csvParser = new CsvReader(sr, CultureInfo.CurrentCulture);
- csvParser.Configuration.HeaderValidated = null;
- csvParser.Configuration.MissingFieldFound = null;
var turnouts = csvParser.GetRecords().ToList();
- using (var dbContext = _serviceProvider.CreateScope().ServiceProvider.GetService())
+ await using (var dbContext = _serviceProvider.CreateScope().ServiceProvider.GetService())
{
EntityFrameworkManager.ContextFactory = context => dbContext;
_dbCounties = await dbContext.Counties.ToListAsync();
diff --git a/src/ElectionResults.API/Startup.cs b/src/ElectionResults.API/Startup.cs
index e0a8ff5..6fa64b1 100644
--- a/src/ElectionResults.API/Startup.cs
+++ b/src/ElectionResults.API/Startup.cs
@@ -48,13 +48,11 @@ public void ConfigureServices(IServiceCollection services)
services
.AddMvc()
- .SetCompatibilityVersion(CompatibilityVersion.Latest)
-
.AddJsonOptions(options =>
{
- options.JsonSerializerOptions.IgnoreNullValues = true;
+ options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter(new SnakeCaseNamingPolicy()));
- }); ;
+ });
services.AddLazyCache();
RegisterDependencies(services, Configuration);
services.AddSwaggerGen(c =>
@@ -63,7 +61,7 @@ public void ConfigureServices(IServiceCollection services)
});
services.AddDbContextPool(options =>
{
- options.UseMySQL(Configuration["ConnectionStrings:DefaultConnection"]
+ options.UseMySQL(Configuration["ConnectionStrings:DefaultConnection"]!
);
});
@@ -81,7 +79,7 @@ public void ConfigureServices(IServiceCollection services)
});
});
- if (Configuration["ScheduleTaskEnabled"].ToLower().Equals("true")) //excuse the primitive syntax
+ if (Configuration["ScheduleTaskEnabled"]!.ToLower().Equals("true")) //excuse the primitive syntax
services.AddHostedService();
}
@@ -151,7 +149,7 @@ private static void MigrateDatabase(ApplicationDbContext context)
}
catch (Exception e)
{
- Console.WriteLine(3);
+ Console.WriteLine(e);
}
}
}
diff --git a/src/ElectionResults.Core/ElectionResults.Core.csproj b/src/ElectionResults.Core/ElectionResults.Core.csproj
index 6de84de..50eab1a 100644
--- a/src/ElectionResults.Core/ElectionResults.Core.csproj
+++ b/src/ElectionResults.Core/ElectionResults.Core.csproj
@@ -1,29 +1,29 @@
-
- netcoreapp3.1
-
+
+ net8.0
+
-
-
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/src/ElectionResults.Core/Extensions/AsyncEx.cs b/src/ElectionResults.Core/Extensions/AsyncEx.cs
deleted file mode 100644
index 3078616..0000000
--- a/src/ElectionResults.Core/Extensions/AsyncEx.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace ElectionResults.Core.Extensions
-{
- public static class AsyncEx
- {
- public static async Task ParallelForEachAsync(this IEnumerable source, Func asyncAction, int maxDegreeOfParallelism = 10)
- {
- var semaphoreSlim = new SemaphoreSlim(maxDegreeOfParallelism);
- var tcs = new TaskCompletionSource