Skip to content

Commit

Permalink
Upgrade to .NET Core 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinVW committed Sep 25, 2019
1 parent 45c6d9f commit c8db950
Show file tree
Hide file tree
Showing 81 changed files with 8,216 additions and 7,264 deletions.
102 changes: 91 additions & 11 deletions src/.vscode/launch.json
Expand Up @@ -4,14 +4,94 @@
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": "Run WebApp",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "",
"program": "${workspaceFolder}/WebApp/bin/Debug/netcoreapp3.0/WebApp.dll",
"args": [],
"cwd": "${workspaceFolder}/WebApp/bin/Debug/netcoreapp3.0",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": "Run CustomerManagementAPI",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "",
"program": "${workspaceFolder}/CustomerManagementAPI/bin/Debug/netcoreapp3.0/Pitstop.CustomerManagementAPI.dll",
"args": [],
"cwd": "${workspaceFolder}/CustomerManagementAPI/bin/Debug/netcoreapp3.0",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": "Run VehicleManagementAPI",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "",
"program": "${workspaceFolder}/VehicleManagementAPI/bin/Debug/netcoreapp3.0/Pitstop.VehicleManagementAPI.dll",
"args": [],
"cwd": "${workspaceFolder}/VehicleManagementAPI/bin/Debug/netcoreapp3.0",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": "Run WorkshopManagementAPI",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "",
"program": "${workspaceFolder}/WorkshopManagementAPI/bin/Debug/netcoreapp3.0/Pitstop.WorkshopManagementAPI.dll",
"args": [],
"cwd": "${workspaceFolder}/WorkshopManagementAPI/bin/Debug/netcoreapp3.0",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": "Run AuditlogService",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/AuditlogService/bin/Debug/netcoreapp2.2/Pitstop.AuditlogService.dll",
"program": "${workspaceFolder}/AuditlogService/bin/Debug/netcoreapp3.0/Pitstop.AuditlogService.dll",
"args": [],
"cwd": "${workspaceFolder}/AuditlogService/bin/Debug/netcoreapp2.2",
"cwd": "${workspaceFolder}/AuditlogService/bin/Debug/netcoreapp3.0",
"stopAtEntry": false,
"console": "externalTerminal",
"env": {
Expand All @@ -23,9 +103,9 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/InvoiceService/bin/Debug/netcoreapp2.2/Pitstop.InvoiceService.dll",
"program": "${workspaceFolder}/InvoiceService/bin/Debug/netcoreapp3.0/Pitstop.InvoiceService.dll",
"args": [],
"cwd": "${workspaceFolder}/InvoiceService/bin/Debug/netcoreapp2.2",
"cwd": "${workspaceFolder}/InvoiceService/bin/Debug/netcoreapp3.0",
"stopAtEntry": false,
"console": "externalTerminal",
"env": {
Expand All @@ -37,9 +117,9 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/NotificationService/bin/Debug/netcoreapp2.2/Pitstop.NotificationService.dll",
"program": "${workspaceFolder}/NotificationService/bin/Debug/netcoreapp3.0/Pitstop.NotificationService.dll",
"args": [],
"cwd": "${workspaceFolder}/NotificationService/bin/Debug/netcoreapp2.2",
"cwd": "${workspaceFolder}/NotificationService/bin/Debug/netcoreapp3.0",
"stopAtEntry": false,
"console": "externalTerminal",
"env": {
Expand All @@ -51,9 +131,9 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/TimeService/bin/Debug/netcoreapp2.2/Pitstop.TimeService.dll",
"program": "${workspaceFolder}/TimeService/bin/Debug/netcoreapp3.0/Pitstop.TimeService.dll",
"args": [],
"cwd": "${workspaceFolder}/TimeService/bin/Debug/netcoreapp2.2",
"cwd": "${workspaceFolder}/TimeService/bin/Debug/netcoreapp3.0",
"stopAtEntry": false,
"console": "externalTerminal",
"env": {
Expand All @@ -64,10 +144,10 @@
"name": "Run WorkshopManagementEventHandler",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/WorkshopManagementEventHandler/bin/Debug/netcoreapp2.2/Pitstop.WorkshopManagementEventHandler.dll",
"preLaunchTask": "",
"program": "${workspaceFolder}/WorkshopManagementEventHandler/bin/Debug/netcoreapp3.0/Pitstop.WorkshopManagementEventHandler.dll",
"args": [],
"cwd": "${workspaceFolder}/WorkshopManagementEventHandler/bin/Debug/netcoreapp2.2",
"cwd": "${workspaceFolder}/WorkshopManagementEventHandler/bin/Debug/netcoreapp3.0",
"stopAtEntry": false,
"console": "externalTerminal",
"env": {
Expand Down
22 changes: 9 additions & 13 deletions src/AuditlogService/AuditlogService.csproj
Expand Up @@ -2,10 +2,10 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Pitstop.AuditlogService</AssemblyName>
<RootNamespace>Pitstop.AuditlogService</RootNamespace>
<LangVersion>7.1</LangVersion>
<RootNamespace>Pitstop.AuditlogService</RootNamespace>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -27,20 +27,16 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="3.0.0" />
<PackageReference Include="Pitstop.Infrastructure.Messaging" Version="2.1.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Serilog" Version="2.8.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="2.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="3.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
</ItemGroup>
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions src/AuditlogService/Dockerfile
@@ -1,4 +1,4 @@
FROM microsoft/dotnet:2.2-sdk AS build-env
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-env
WORKDIR /app

# Copy necessary files and restore as distinct layer
Expand All @@ -11,7 +11,7 @@ COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM microsoft/dotnet:2.2-runtime
FROM mcr.microsoft.com/dotnet/core/runtime:3.0
COPY --from=build-env /app/out .

# Start
Expand Down
2 changes: 1 addition & 1 deletion src/AuditlogService/Program.cs
Expand Up @@ -20,7 +20,7 @@ public static async Task Main(string[] args)

private static IHostBuilder CreateHostBuilder(string[] args)
{
var hostBuilder = new HostBuilder()
var hostBuilder = Host.CreateDefaultBuilder(args)
.ConfigureHostConfiguration(configHost =>
{
configHost.SetBasePath(Directory.GetCurrentDirectory());
Expand Down
2 changes: 0 additions & 2 deletions src/CustomerManagementAPI/Commands/RegisterCustomer.cs
@@ -1,7 +1,5 @@
using Pitstop.Infrastructure.Messaging;
using System;
using System.Collections.Generic;
using System.Text;

namespace Pitstop.CustomerManagementAPI.Commands
{
Expand Down
9 changes: 6 additions & 3 deletions src/CustomerManagementAPI/Controllers/CustomersController.cs
Expand Up @@ -4,10 +4,12 @@
using Microsoft.AspNetCore.Http;
using Pitstop.CustomerManagementAPI.DataAccess;
using Pitstop.CustomerManagementAPI.Model;
using AutoMapper;
using Pitstop.Infrastructure.Messaging;
using Pitstop.CustomerManagementAPI.Events;
using Pitstop.CustomerManagementAPI.Commands;
using Pitstop.CustomerManagementAPI.Mappers;
using Serilog;
using System;

namespace Pitstop.Application.CustomerManagementAPI.Controllers
{
Expand Down Expand Up @@ -49,12 +51,12 @@ public async Task<IActionResult> RegisterAsync([FromBody] RegisterCustomer comma
if (ModelState.IsValid)
{
// insert customer
Customer customer = Mapper.Map<Customer>(command);
Customer customer = command.MapToCustomer();
_dbContext.Customers.Add(customer);
await _dbContext.SaveChangesAsync();

// send event
CustomerRegistered e = Mapper.Map<CustomerRegistered>(command);
CustomerRegistered e = command.MapToCustomerRegistered();
await _messagePublisher.PublishMessageAsync(e.MessageType, e , "");

// return result
Expand All @@ -68,6 +70,7 @@ public async Task<IActionResult> RegisterAsync([FromBody] RegisterCustomer comma
"Try again, and if the problem persists " +
"see your system administrator.");
return StatusCode(StatusCodes.Status500InternalServerError);
throw;
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/CustomerManagementAPI/CustomerManagementAPI.csproj
@@ -1,25 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Pitstop.CustomerManagementAPI</AssemblyName>
<RootNamespace>Pitstop.CustomerManagementAPI</RootNamespace>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.HealthChecks.SqlServer" Version="1.0.0" />
<PackageReference Include="Pitstop.Infrastructure.Messaging" Version="2.1.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="AutoMapper" Version="8.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="Pitstop.Infrastructure.Messaging" Version="2.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2" />
<PackageReference Include="Serilog.AspNetCore" Version="3.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
</ItemGroup>
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>

</Project>
4 changes: 2 additions & 2 deletions src/CustomerManagementAPI/Dockerfile
@@ -1,4 +1,4 @@
FROM microsoft/dotnet:2.2-sdk AS build-env
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-env
WORKDIR /app

# Copy necessary files and restore as distinct layer
Expand All @@ -10,7 +10,7 @@ COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM microsoft/dotnet:2.2-aspnetcore-runtime
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0
COPY --from=build-env /app/out .

# Expose ports
Expand Down
3 changes: 2 additions & 1 deletion src/CustomerManagementAPI/Events/CustomerRegistered.cs
@@ -1,4 +1,5 @@
using Pitstop.Infrastructure.Messaging;
using Pitstop.CustomerManagementAPI.Commands;
using Pitstop.Infrastructure.Messaging;
using System;
using System.Collections.Generic;
using System.Text;
Expand Down
32 changes: 32 additions & 0 deletions src/CustomerManagementAPI/Mappers/Mappers.cs
@@ -0,0 +1,32 @@
using Pitstop.CustomerManagementAPI.Commands;
using Pitstop.CustomerManagementAPI.Events;
using Pitstop.CustomerManagementAPI.Model;

namespace Pitstop.CustomerManagementAPI.Mappers
{
public static class Mappers
{
public static CustomerRegistered MapToCustomerRegistered(this RegisterCustomer command) => new CustomerRegistered
(
System.Guid.NewGuid(),
command.CustomerId,
command.Name,
command.Address,
command.PostalCode,
command.City,
command.TelephoneNumber,
command.EmailAddress
);

public static Customer MapToCustomer(this RegisterCustomer command) => new Customer
{
CustomerId = command.CustomerId,
Name = command.Name,
Address = command.Address,
PostalCode = command.PostalCode,
City = command.City,
TelephoneNumber = command.TelephoneNumber,
EmailAddress = command.EmailAddress
};
}
}
1 change: 1 addition & 0 deletions src/CustomerManagementAPI/Model/Customer.cs
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.Configuration;
using Pitstop.CustomerManagementAPI.Commands;

namespace Pitstop.CustomerManagementAPI.Model
{
Expand Down

0 comments on commit c8db950

Please sign in to comment.