Skip to content

Commit

Permalink
Merge branch 'neozhu:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkey authored Dec 31, 2023
2 parents 45c225a + a2799e2 commit 4f03a84
Show file tree
Hide file tree
Showing 679 changed files with 49,082 additions and 43,410 deletions.
4,053 changes: 3,723 additions & 330 deletions .editorconfig

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ jobs:

- name: Restore dependencies
run: dotnet restore CleanArchitecture.Blazor.sln

- name: Build
run: dotnet build CleanArchitecture.Blazor.sln --configuration Debug --no-restore

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Restore dependencies
run: dotnet restore CleanArchitecture.Blazor.sln
- name: Build
run: dotnet build CleanArchitecture.Blazor.sln --no-restore --configuration Release
run: dotnet build CleanArchitecture.Blazor.sln --configuration Debug --no-restore
# - name: Test
# run: dotnet test CleanArchitecture.Blazor.sln --no-build --configuration Release --filter "FullyQualifiedName!~AcceptanceTests"
env:
Expand Down
60 changes: 31 additions & 29 deletions CleanArchitecture.Blazor.nuspec
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>CleanArchitecture.Blazor.Solution.Template</id>
<version>1.0.0-preview.17</version>
<title>Clean Architecture Blazor Solution Template</title>
<authors>hl.z</authors>
<description>Clean Architecture Blazor Solution Template for .NET 8.</description>
<summary>
A Clean Architecture Blazor Server Solution Template for creating a Single-Page Application (SPA) with ASP.NET Core.
</summary>
<releaseNotes>
1.0.0-preview.17
- 🌈 support.net 8
</releaseNotes>
<metadata>
<id>CleanArchitecture.Blazor.Solution.Template</id>
<version>1.0.0-preview.17</version>
<title>Clean Architecture Blazor Solution Template</title>
<authors>hl.z</authors>
<description>Clean Architecture Blazor Solution Template for .NET 8.</description>
<summary>
A Clean Architecture Blazor Server Solution Template for creating a Single-Page Application (SPA) with
ASP.NET Core.
</summary>
<releaseNotes>
1.0.0-preview.17
- 🌈 support.net 8
</releaseNotes>

<projectUrl>https://github.com/neozhu/CleanArchitectureWithBlazorServer</projectUrl>
<repository type="git" url="https://github.com/neozhu/CleanArchitectureWithBlazorServer.git" branch="main" />
<projectUrl>https://github.com/neozhu/CleanArchitectureWithBlazorServer</projectUrl>
<repository type="git" url="https://github.com/neozhu/CleanArchitectureWithBlazorServer.git" branch="main"/>

<license type="expression">MIT</license>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<tags>clean-architecture blazor server application project template csharp </tags>
<icon>icon.png</icon>
<readme>README.md</readme>
<license type="expression">MIT</license>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<tags>clean-architecture blazor server application project template csharp</tags>
<icon>icon.png</icon>
<readme>README.md</readme>

<packageTypes>
<packageType name="Template" />
</packageTypes>
</metadata>
<packageTypes>
<packageType name="Template"/>
</packageTypes>
</metadata>

<files>
<file src=".template.config\icon.png" />
<file src="README.md" />
<file src=".\**" target="content" exclude=".template.config\**;*.exe\;*\bin\**;**\obj\**;**\.vs\**;**\.vscode\**;**\wwwroot\dist\**;content\Directory.Build.*;**\.git\**;**\.github\**;**\CODE_OF_CONDUCT.md;**\LICENSE;**\README.md;" />
</files>
<files>
<file src=".template.config\icon.png"/>
<file src="README.md"/>
<file src=".\**" target="content"
exclude=".template.config\**;*.exe\;*\bin\**;**\obj\**;**\.vs\**;**\.vscode\**;**\wwwroot\dist\**;content\Directory.Build.*;**\.git\**;**\.github\**;**\CODE_OF_CONDUCT.md;**\LICENSE;**\README.md;"/>
</files>

</package>
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ Blazor technology.
## Docker compose https deployment

- Create self-signed development certificates for the project
- cmd: `dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\CleanArchitecture.Blazor.Server.UI.pfx -p Password@123`
-
cmd: `dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\CleanArchitecture.Blazor.Server.UI.pfx -p Password@123`
- cmd: `dotnet dev-certs https --trust`
- Manage User secrets to save the password
- cmd: `dotnet user-secrets init`
Expand All @@ -52,32 +53,34 @@ Blazor technology.
<div><video controls src="https://user-images.githubusercontent.com/1549611/197116874-f28414ca-7fc1-463a-b887-0754a5bb3e01.mp4" muted="false"></video></div>

### Install CleanArchitecture CodeGenerator For Blazor App

- Open Manage Extensions Search with `CleanArchitecture CodeGenerator For Blaozr App`
![image](https://github.com/neozhu/CleanArchitectureWithBlazorServer/assets/1549611/555d274c-8f62-438b-ac7a-6d327e4c23c8)
![image](https://github.com/neozhu/CleanArchitectureWithBlazorServer/assets/1549611/555d274c-8f62-438b-ac7a-6d327e4c23c8)
- Download to Install

### CleanArchitecture CodeGenerator For Blazor App Repo

- https://github.com/neozhu/CleanArchitectureCodeGenerator
- The code generator can automatically generate the standard code
- Application Layer Code

- ![image](https://user-images.githubusercontent.com/1549611/181414766-84850a90-3a21-47ed-afcf-1b5cdd602edf.png)
- Domain Event

- ![image](https://user-images.githubusercontent.com/1549611/183537303-058d6f49-fc45-4b77-8924-cc2e8266cad7.png)
- Blazor UI Layer Code

- ![image](https://user-images.githubusercontent.com/1549611/181414818-5c1c2dfc-5560-4ab2-8773-dc7c816730d4.png)
- Task List

- ![image](https://user-images.githubusercontent.com/1549611/183537444-3d1b2980-b131-4e9d-bfe1-7b475f760b57.png)

## How to install solution templates

- install the project template
- run CLI: `dotnet new install ./`
- run CLI: `dotnet new list`

<img width="828" alt="image" src="https://github.com/neozhu/CleanArchitectureWithBlazorServer/assets/1549611/f23022e0-3fd6-475a-96ab-84b0d3328e4c">

- create a solution with the template
Expand All @@ -90,12 +93,10 @@ Blazor technology.
- create a new project from Clean Architecture for Blazor Server Solution
<img width="769" alt="image" src="https://github.com/neozhu/CleanArchitectureWithBlazorServer/assets/1549611/ed7eb20f-aec2-4f69-95b7-d47c2eb20428">




## Why I chose Blazor Server

- I hate switching between C# and JavaScript at the same time in order to develop a project, which is why I opted for Blazor Server.
- I hate switching between C# and JavaScript at the same time in order to develop a project, which is why I opted for
Blazor Server.

## Characteristic

Expand Down
38 changes: 19 additions & 19 deletions docker-compose.dcproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<ProjectGuid>6bd2ec46-fa8f-44f3-af33-903bbb347116</ProjectGuid>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}</DockerServiceUrl>
<DockerServiceName>dashboard</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.yml" />
<None Include="docker-compose.override.yml" />
<None Include=".dockerignore" />
</ItemGroup>
<ItemGroup>
<None Remove="launchSettings.json" />
</ItemGroup>
<ItemGroup>
<None Remove="src\**" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<ProjectGuid>6bd2ec46-fa8f-44f3-af33-903bbb347116</ProjectGuid>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}</DockerServiceUrl>
<DockerServiceName>dashboard</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.yml"/>
<None Include="docker-compose.override.yml"/>
<None Include=".dockerignore"/>
</ItemGroup>
<ItemGroup>
<None Remove="launchSettings.json"/>
</ItemGroup>
<ItemGroup>
<None Remove="src\**"/>
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ services:
#- ASPNETCORE_Kestrel__Certificates__Default__Password=Password@123
#- ASPNETCORE_Kestrel__Certificates__Default__Path=/root/.aspnet/https/CleanArchitecture.Blazor.Server.UI.pfx
volumes:
- ${APPDATA}\microsoft\UserSecrets\:/root/.microsoft/usersecrets:ro
- ~/.aspnet/https:/root/.aspnet/https:ro
- ${APPDATA}\microsoft\UserSecrets\:/root/.microsoft/usersecrets:ro
- ~/.aspnet/https:/root/.aspnet/https:ro
ports:
- "5000:80"
- "5001:443"
Expand Down
4 changes: 2 additions & 2 deletions src/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<PackageReference Include="jcamp.FluentEmail.Razor" Version="3.7.0" />
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="FluentValidation" Version="11.8.1" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.8.1" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" />
<PackageReference Include="LazyCache" Version="2.4.0" />
<PackageReference Include="LazyCache.AspNetCore" Version="2.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
// return Task.CompletedTask;
// }
//}

Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
// return Task.CompletedTask;
// }
//}

Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
// return Task.CompletedTask;
// }
//}

7 changes: 5 additions & 2 deletions src/Application/Common/ExceptionHandlers/ConflictException.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System.Net;

namespace CleanArchitecture.Blazor.Application.Common.ExceptionHandlers;

public class ConflictException : ServerException
{
public ConflictException(string message)
: base(message, System.Net.HttpStatusCode.Conflict)
: base(message, HttpStatusCode.Conflict)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ private static string[] GetErrors(DbUpdateException exception)
&& exception.InnerException != null
&& exception.InnerException is SqlException sqlException
)
{
switch (sqlException.Number)
{
case 2627: // Unique constraint error
Expand All @@ -52,7 +51,6 @@ private static string[] GetErrors(DbUpdateException exception)
errors.Add("A Missing Parameter has led to Error While Creating the record(s)!");
break;
}
}


return errors.ToArray();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Net;

namespace CleanArchitecture.Blazor.Application.Common.ExceptionHandlers;

public class ForbiddenException : ServerException
{
public ForbiddenException(string message) : base(message,System.Net.HttpStatusCode.Forbidden) { }
}
public ForbiddenException(string message) : base(message, HttpStatusCode.Forbidden)
{
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace CleanArchitecture.Blazor.Application.Common.ExceptionHandlers;

public class InternalServerException : ServerException
{
public InternalServerException(string message)
: base(message, System.Net.HttpStatusCode.InternalServerError)
: base(message)
{
}
}
13 changes: 7 additions & 6 deletions src/Application/Common/ExceptionHandlers/NotFoundException.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Net;

namespace CleanArchitecture.Blazor.Application.Common.ExceptionHandlers;

public class NotFoundException : ServerException
{


public NotFoundException(string message)
: base(message,System.Net.HttpStatusCode.NotFound)
: base(message, HttpStatusCode.NotFound)
{
}
public NotFoundException(string name, object key)
: base($"Entity \"{name}\" ({key}) was not found.", System.Net.HttpStatusCode.NotFound)

public NotFoundException(string name, object key)
: base($"Entity \"{name}\" ({key}) was not found.", HttpStatusCode.NotFound)
{
}
}
}
11 changes: 6 additions & 5 deletions src/Application/Common/ExceptionHandlers/ServerException.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
using System.Net;

namespace CleanArchitecture.Blazor.Application.Common.ExceptionHandlers;

public class ServerException : Exception
{
public IEnumerable<string> ErrorMessages { get; }

public HttpStatusCode StatusCode { get; }

public ServerException(string message, HttpStatusCode statusCode = HttpStatusCode.InternalServerError)
: base(message)
{
ErrorMessages = new string[] { message };
ErrorMessages = new[] { message };
StatusCode = statusCode;
}

public IEnumerable<string> ErrorMessages { get; }

public HttpStatusCode StatusCode { get; }
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
namespace CleanArchitecture.Blazor.Application.Common.ExceptionHandlers;
public class ServerExceptionHandler<TRequest, TResponse, TException> : IRequestExceptionHandler<TRequest, TResponse, TException>

public class
ServerExceptionHandler<TRequest, TResponse, TException> : IRequestExceptionHandler<TRequest, TResponse, TException>
where TRequest : IRequest<Result<int>>
where TResponse: Result<int>
where TResponse : Result<int>
where TException : ServerException
{
private readonly ILogger<ServerExceptionHandler<TRequest, TResponse, TException>> _logger;
Expand All @@ -11,11 +13,10 @@ public ServerExceptionHandler(ILogger<ServerExceptionHandler<TRequest, TResponse
_logger = logger;
}

public Task Handle(TRequest request, TException exception, RequestExceptionHandlerState<TResponse> state, CancellationToken cancellationToken)
public Task Handle(TRequest request, TException exception, RequestExceptionHandlerState<TResponse> state,
CancellationToken cancellationToken)
{
state.SetHandled((TResponse)Result<int>.Failure(new string[] { exception.Message }));
state.SetHandled((TResponse)Result<int>.Failure(exception.Message));
return Task.CompletedTask;
}


}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Net;

namespace CleanArchitecture.Blazor.Application.Common.ExceptionHandlers;

public class UnauthorizedException : ServerException
{
public UnauthorizedException(string message)
: base(message, System.Net.HttpStatusCode.Unauthorized)
: base(message, HttpStatusCode.Unauthorized)
{
}
}

}
Loading

0 comments on commit 4f03a84

Please sign in to comment.