Skip to content

Commit acb2fd3

Browse files
authored
Merge pull request #15 from sj-distributor/dotnet9
Upgrade to dotnet9
2 parents 6229030 + 589f13a commit acb2fd3

File tree

92 files changed

+884
-1266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+884
-1266
lines changed

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup .NET
2020
uses: actions/setup-dotnet@v3
2121
with:
22-
dotnet-version: 7.0.x
22+
dotnet-version: 9.0.x
2323
- name: Restore dependencies
2424
run: dotnet restore
2525
- name: Build

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![.NET](https://github.com/sj-distributor/Wax/actions/workflows/dotnet.yml/badge.svg)](https://github.com/sj-distributor/Wax/actions/workflows/dotnet.yml)
44
[![Nuget](https://img.shields.io/nuget/v/Wax.Template)](https://www.nuget.org/packages/Wax.Template)
55

6-
WilTechs Architecture Solution Template for .NET 7
6+
WilTechs Architecture Solution Template for .NET 9
77

88
## Getting Started
99

Wax.sln

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{75759C27-8B1
99
EndProject
1010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{39D26C72-1BD3-4793-A455-F651830208E7}"
1111
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wax.Messages", "src\Wax.Messages\Wax.Messages.csproj", "{E378200E-C104-4263-940C-24EAC2C5EF8B}"
13-
EndProject
1412
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wax.Api", "src\Wax.Api\Wax.Api.csproj", "{43B01DB0-00F2-48F3-962A-62236758544A}"
1513
EndProject
1614
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wax.UnitTests", "tests\Wax.UnitTests\Wax.UnitTests.csproj", "{AF0CBC87-76A5-4592-8673-7F4E2DA589F9}"
1715
EndProject
1816
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wax.IntegrationTests", "tests\Wax.IntegrationTests\Wax.IntegrationTests.csproj", "{1A1B03CC-0E42-46A0-9F7E-6DE18F05679B}"
1917
EndProject
20-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wax.E2ETests", "tests\Wax.E2ETests\Wax.E2ETests.csproj", "{959A9B6E-2410-4F4A-A73C-1A69A41EE0A6}"
18+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wax.Infrastructure", "src\Wax.Infrastructure\Wax.Infrastructure.csproj", "{7B557ED6-760C-4FF4-A720-E5D9D887F2C6}"
2119
EndProject
2220
Global
2321
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -29,10 +27,6 @@ Global
2927
{26DEE87D-1B2C-4788-B8DA-55F29896C03A}.Debug|Any CPU.Build.0 = Debug|Any CPU
3028
{26DEE87D-1B2C-4788-B8DA-55F29896C03A}.Release|Any CPU.ActiveCfg = Release|Any CPU
3129
{26DEE87D-1B2C-4788-B8DA-55F29896C03A}.Release|Any CPU.Build.0 = Release|Any CPU
32-
{E378200E-C104-4263-940C-24EAC2C5EF8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33-
{E378200E-C104-4263-940C-24EAC2C5EF8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
34-
{E378200E-C104-4263-940C-24EAC2C5EF8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
35-
{E378200E-C104-4263-940C-24EAC2C5EF8B}.Release|Any CPU.Build.0 = Release|Any CPU
3630
{43B01DB0-00F2-48F3-962A-62236758544A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3731
{43B01DB0-00F2-48F3-962A-62236758544A}.Debug|Any CPU.Build.0 = Debug|Any CPU
3832
{43B01DB0-00F2-48F3-962A-62236758544A}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -45,21 +39,20 @@ Global
4539
{1A1B03CC-0E42-46A0-9F7E-6DE18F05679B}.Debug|Any CPU.Build.0 = Debug|Any CPU
4640
{1A1B03CC-0E42-46A0-9F7E-6DE18F05679B}.Release|Any CPU.ActiveCfg = Release|Any CPU
4741
{1A1B03CC-0E42-46A0-9F7E-6DE18F05679B}.Release|Any CPU.Build.0 = Release|Any CPU
48-
{959A9B6E-2410-4F4A-A73C-1A69A41EE0A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49-
{959A9B6E-2410-4F4A-A73C-1A69A41EE0A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
50-
{959A9B6E-2410-4F4A-A73C-1A69A41EE0A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
51-
{959A9B6E-2410-4F4A-A73C-1A69A41EE0A6}.Release|Any CPU.Build.0 = Release|Any CPU
42+
{7B557ED6-760C-4FF4-A720-E5D9D887F2C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43+
{7B557ED6-760C-4FF4-A720-E5D9D887F2C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
44+
{7B557ED6-760C-4FF4-A720-E5D9D887F2C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
45+
{7B557ED6-760C-4FF4-A720-E5D9D887F2C6}.Release|Any CPU.Build.0 = Release|Any CPU
5246
EndGlobalSection
5347
GlobalSection(SolutionProperties) = preSolution
5448
HideSolutionNode = FALSE
5549
EndGlobalSection
5650
GlobalSection(NestedProjects) = preSolution
5751
{26DEE87D-1B2C-4788-B8DA-55F29896C03A} = {75759C27-8B18-4FB5-97A8-570BBE311C6B}
58-
{E378200E-C104-4263-940C-24EAC2C5EF8B} = {75759C27-8B18-4FB5-97A8-570BBE311C6B}
5952
{43B01DB0-00F2-48F3-962A-62236758544A} = {75759C27-8B18-4FB5-97A8-570BBE311C6B}
6053
{AF0CBC87-76A5-4592-8673-7F4E2DA589F9} = {39D26C72-1BD3-4793-A455-F651830208E7}
6154
{1A1B03CC-0E42-46A0-9F7E-6DE18F05679B} = {39D26C72-1BD3-4793-A455-F651830208E7}
62-
{959A9B6E-2410-4F4A-A73C-1A69A41EE0A6} = {39D26C72-1BD3-4793-A455-F651830208E7}
55+
{7B557ED6-760C-4FF4-A720-E5D9D887F2C6} = {75759C27-8B18-4FB5-97A8-570BBE311C6B}
6356
EndGlobalSection
6457
GlobalSection(ExtensibilityGlobals) = postSolution
6558
SolutionGuid = {60CBA761-5D3C-4D33-B808-977512C7E6ED}

src/Wax.Api/Authentication/CurrentUser.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
using Mediator.Net;
2-
using Microsoft.AspNetCore.Mvc;
3-
using Wax.Messages.Commands.Customers;
4-
using Wax.Messages.Dtos.Customers;
5-
using Wax.Messages.Requests;
6-
using Wax.Messages.Requests.Customers;
7-
81
namespace Wax.Api.Controllers
92
{
103
[ApiController]
@@ -22,7 +15,8 @@ public CustomerController(IMediator mediator)
2215
[ProducesResponseType(typeof(PaginatedResponse<CustomerShortInfo>), 200)]
2316
public async Task<IActionResult> GetListAsync([FromQuery] GetCustomersRequest request)
2417
{
25-
var response = await _mediator.RequestAsync<GetCustomersRequest, PaginatedResponse<CustomerShortInfo>>(request);
18+
var response =
19+
await _mediator.RequestAsync<GetCustomersRequest, PaginatedResponse<CustomerShortInfo>>(request);
2620

2721
return Ok(response);
2822
}
@@ -32,23 +26,30 @@ public async Task<IActionResult> GetListAsync([FromQuery] GetCustomersRequest re
3226
public async Task<IActionResult> CreateAsync([FromBody] CreateCustomerCommand command)
3327
{
3428
var response = await _mediator.SendAsync<CreateCustomerCommand, CreateCustomerResponse>(command);
35-
return Ok(response);
29+
return CreatedAtAction("GetList", response);
3630
}
3731

38-
[HttpPut]
39-
[ProducesResponseType(200)]
40-
public async Task<IActionResult> UpdateAsync([FromBody] UpdateCustomerCommand command)
32+
[HttpPut("{customerId:guid}")]
33+
[ProducesResponseType(204)]
34+
public async Task<IActionResult> UpdateAsync(Guid customerId, [FromBody] UpdateCustomerModel model)
4135
{
42-
await _mediator.SendAsync(command);
43-
return Ok();
36+
await _mediator.SendAsync(new UpdateCustomerCommand
37+
{
38+
CustomerId = customerId,
39+
Name = model.Name,
40+
Contact = model.Contact,
41+
Address = model.Address
42+
});
43+
44+
return NoContent();
4445
}
4546

4647
[HttpDelete]
47-
[ProducesResponseType(200)]
48+
[ProducesResponseType(204)]
4849
public async Task<IActionResult> DeleteAsync([FromBody] DeleteCustomerCommand command)
4950
{
5051
await _mediator.SendAsync(command);
51-
return Ok();
52+
return NoContent();
5253
}
5354
}
5455
}

src/Wax.Api/Filters/GlobalExceptionFilter.cs

Lines changed: 0 additions & 101 deletions
This file was deleted.

src/Wax.Api/GlobalUsings.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Global using directives
2+
3+
global using Autofac;
4+
global using Mediator.Net;
5+
global using Microsoft.AspNetCore.Mvc;
6+
global using Serilog;
7+
global using Wax.Api.Extensions;
8+
global using Wax.Api.Models;
9+
global using Wax.Core;
10+
global using Wax.Core.Commands.Customers;
11+
global using Wax.Core.Requests;
12+
global using Wax.Core.Requests.Customers;
13+
global using Wax.Infrastructure;
14+
global using ILogger = Serilog.ILogger;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Wax.Api.Models;
2+
3+
public class UpdateCustomerModel
4+
{
5+
public string Name { get; set; }
6+
public string Contact { get; set; }
7+
public string Address { get; set; }
8+
}

src/Wax.Api/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Autofac.Extensions.DependencyInjection;
2-
using Serilog;
32

43
namespace Wax.Api;
54

@@ -47,7 +46,7 @@ private static IConfiguration GetConfiguration()
4746
return builder.Build();
4847
}
4948

50-
private static Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
49+
private static ILogger CreateSerilogLogger(IConfiguration configuration)
5150
{
5251
var seqServerUrl = configuration["Serilog:Seq:ServerUrl"];
5352
var seqApiKey = configuration["Serilog:Seq:ApiKey"];

src/Wax.Api/Startup.cs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
using Autofac;
2-
using Wax.Api.Authentication;
3-
using Wax.Api.Extensions;
4-
using Wax.Core.Services.Identity;
5-
using Serilog;
6-
using Wax.Api.Filters;
7-
using Wax.Core;
8-
9-
namespace Wax.Api;
1+
namespace Wax.Api;
102

113
public class Startup
124
{
@@ -23,10 +15,10 @@ public Startup(IConfiguration configuration)
2315
// called by the runtime before the ConfigureContainer method, below.
2416
public void ConfigureServices(IServiceCollection services)
2517
{
26-
services.AddControllers(options => { options.Filters.Add<GlobalExceptionFilter>(); });
18+
services.AddControllers();
2719
services.AddOptions();
2820
services.AddCustomSwagger();
29-
services.AddScoped<ICurrentUser, CurrentUser>();
21+
services.AddScoped<IUserContext, UserContext>();
3022
services.AddLogging();
3123
services.AddHttpContextAccessor();
3224

@@ -41,13 +33,9 @@ public void ConfigureContainer(ContainerBuilder builder)
4133
{
4234
var serviceProvider = _serviceCollection.BuildServiceProvider();
4335

44-
var currentUser = serviceProvider.GetRequiredService<ICurrentUser>();
36+
var userContext = serviceProvider.GetRequiredService<IUserContext>();
4537

46-
// Register your own things directly with Autofac here. Don't
47-
// call builder.Populate(), that happens in AutofacServiceProviderFactory
48-
// for you.
49-
builder.RegisterModule(new ApplicationModule(Log.Logger, currentUser, Configuration,
50-
typeof(Startup).Assembly));
38+
ApplicationStartup.Initialize(builder, "", Log.Logger, userContext, Configuration);
5139
}
5240

5341
// Configure is where you add middleware. This is called after
@@ -58,7 +46,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
5846
if (env.IsDevelopment())
5947
{
6048
app.UseSwagger();
61-
app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Barcode.Api.xml"); });
49+
app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Wax.Api.xml"); });
6250
}
6351

6452
app.UseRouting();

0 commit comments

Comments
 (0)